关于原子引擎的交换声明是否为多个表提供原子能?

发布于 2025-02-03 09:41:53 字数 468 浏览 1 评论 0原文

文档声明原子质用于交换两个表格,但是多个表格呢?以下查询效果很好,并在表中执行交换a< => bc< => D

EXCHANGE TABLES "default"."A" AND "default"."B", "default"."C" AND "default"."D"

关于原子引擎的交换语句是否为多个表提供原子能吗? 当a< =>时可能是情况。 b交换但c< => D不是吗?原子性在整个交换查询上会传播吗?

Documentation declares Atomicity for exchanging two tables, but what about multiple tables? Following query works well and perform exchanging within tables A <=> B and C <=> D:

EXCHANGE TABLES "default"."A" AND "default"."B", "default"."C" AND "default"."D"

Does EXCHANGE statement on Atomic engine provide atomic capabilities for multiple tables?
Can be situation when A <=> B exchanged but C <=> D not? Does atomicity spreads on whole EXCHANGE query?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

恏ㄋ傷疤忘ㄋ疼 2025-02-10 09:41:53

他们不是原子。

insert into a.x1 select 1;
insert into a.x1 select 2;

exchange tables a.x1 and a.x2, a.y1 and a.y2;

Received exception from server (version 22.6.1):
Code: 521. DB::Exception: Received from localhost:9000.DB::ErrnoException: Paths cannot be exchanged because /var/lib/clickhouse/store/209/209474d2-5d64-4ca0-8b45-9abf4109235a/y1.sql or /var/lib/clickhouse/store/209/209474d2-5d64-4ca0-8b45-9abf4109235a/y2.sql does not exist, errno: 2, strerror: No such file or directory. (ATOMIC_RENAME_FAIL)

select * from a.x1;
Ok.
0 rows in set. Elapsed: 0.002 sec.


select * from a.x2
┌─A─┐
│ 2 │
└───┘
┌─A─┐
│ 1 │
└───┘

原子与DML交易无关。这是关于选择的可见性。该查询没有看到中间状态,也不会投掷表。不存在...

They are not atomic.

insert into a.x1 select 1;
insert into a.x1 select 2;

exchange tables a.x1 and a.x2, a.y1 and a.y2;

Received exception from server (version 22.6.1):
Code: 521. DB::Exception: Received from localhost:9000.DB::ErrnoException: Paths cannot be exchanged because /var/lib/clickhouse/store/209/209474d2-5d64-4ca0-8b45-9abf4109235a/y1.sql or /var/lib/clickhouse/store/209/209474d2-5d64-4ca0-8b45-9abf4109235a/y2.sql does not exist, errno: 2, strerror: No such file or directory. (ATOMIC_RENAME_FAIL)

select * from a.x1;
Ok.
0 rows in set. Elapsed: 0.002 sec.


select * from a.x2
┌─A─┐
│ 2 │
└───┘
┌─A─┐
│ 1 │
└───┘

Atomicy is not about DML transactions. It's about visibility for selects. That queries do not see intermediate state and do not throw table . does not exists...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文