Clickhouse 无法更改列抛出 DB::Exception:副本上的元数据与 Zookeeper 中的公共元数据不同步

Clickhouse cannot alter columns throws DB::Exception: Metadata on replica is not up to date with common metadata in Zookeeper

我在两个节点上有一个复制的合并树table

我有两列 client_port 和 server_port Int16,我想将其更改为 UInt16。 table 目前有很多数据(大约 1.2TB,200 亿行)

关于运行这些查询,

Alter table events_db.events_local_tables ON cluster click_cluster modify COLUMN client_port `UInt16`

Alter table events_db.events_local_tables ON cluster click_cluster modify COLUMN server_port `UInt16`

client_port 不是直截了当的,它在 1 个节点上进行了更改,但对于另一个节点,我们必须手动重启所有 zookeeper 服务。最终设法更改 client_port 但相同的流程不适用于 server_port 失败。它抛出以下异常。

2021.09.20 20:24:16.761842 [ 38517 ] {806f2936-b668-41aa-ab7c-16c485393b17} <Debug> executeQuery: (from 10.120.1.122:54962)  /*TABIX_QUERY_ID_uUtFccK4*/ Alter table events_db.events_local_tables ON cluster click_cluster modify COLUMN server_port `UInt16`
2021.09.20 20:24:16.761941 [ 38517 ] {806f2936-b668-41aa-ab7c-16c485393b17} <Trace> ContextAccess (default): Access granted: ALTER MODIFY COLUMN(server_port) ON events_db.events_local_tables
2021.09.20 20:24:16.773835 [ 38666 ] {} <Debug> DDLWorker: Processing task query-0000000482 (ALTER TABLE events_db.events_local_tables ON CLUSTER click_cluster MODIFY COLUMN `server_port` UInt16)
2021.09.20 20:24:16.779570 [ 38666 ] {} <Debug> DDLWorker: Executing query: ALTER TABLE events_db.events_local_tables MODIFY COLUMN `server_port` UInt16
2021.09.20 20:24:16.795296 [ 38666 ] {fb879340-1376-4af0-927b-4e8b73575841} <Debug> executeQuery: (from 0.0.0.0:0, user: ) /* ddl_entry=query-0000000482 */ ALTER TABLE events_db.events_local_tables MODIFY COLUMN `server_port` UInt16
2021.09.20 20:24:16.832801 [ 38666 ] {fb879340-1376-4af0-927b-4e8b73575841} <Error> executeQuery: Code: 517. DB::Exception: Metadata on replica is not up to date with common metadata in Zookeeper. Cannot alter. (CANNOT_ASSIGN_ALTER) (version 21.9.2.17 (official build)) (from 0.0.0.0:0) (in query: /* ddl_entry=query-0000000482 */ ALTER TABLE events_db.events_local_tables MODIFY COLUMN `server_port` UInt16), Stack trace (when copying this message, always include the lines below):
2021.09.20 20:24:16.833070 [ 38666 ] {fb879340-1376-4af0-927b-4e8b73575841} <Error> DDLWorker: Query ALTER TABLE events_db.events_local_tables MODIFY COLUMN `server_port` UInt16 wasn't finished successfully: Code: 517. DB::Exception: Metadata on replica is not up to date with common metadata in Zookeeper. Cannot alter. (CANNOT_ASSIGN_ALTER), Stack trace (when copying this message, always include the lines below):
2021.09.20 20:24:17.274010 [ 38666 ] {b001d5b7-d564-413d-82fc-001ec82906b6} <Debug> executeQuery: (from 0.0.0.0:0, user: ) /* ddl_entry=query-0000000482 */ ALTER TABLE events_db.events_local_tables MODIFY COLUMN `server_port` UInt16
2021.09.20 20:24:17.313598 [ 38666 ] {b001d5b7-d564-413d-82fc-001ec82906b6} <Error> executeQuery: Code: 517. DB::Exception: Metadata on replica is not up to date with common metadata in Zookeeper. Cannot alter. (CANNOT_ASSIGN_ALTER) (version 21.9.2.17 (official build)) (from 0.0.0.0:0) (in query: /* ddl_entry=query-0000000482 */ ALTER TABLE events_db.events_local_tables MODIFY COLUMN `server_port` UInt16), Stack trace (when copying this message, always include the lines below):
2021.09.20 20:24:17.313893 [ 38666 ] {b001d5b7-d564-413d-82fc-001ec82906b6} <Error> DDLWorker: Query ALTER TABLE events_db.events_local_tables MODIFY COLUMN `server_port` UInt16 wasn't finished successfully: Code: 517. DB::Exception: Metadata on replica is not up to date with common metadata in Zookeeper. Cannot alter. (CANNOT_ASSIGN_ALTER), Stack trace (when copying this message, always include the lines below):
2021.09.20 20:24:17.429943 [ 38666 ] {2db93657-4c33-4b9d-8817-653f9706a27c} <Debug> executeQuery: (from 0.0.0.0:0, user: ) /* ddl_entry=query-0000000482 */ ALTER TABLE events_db.events_local_tables MODIFY COLUMN `server_port` UInt16
2021.09.20 20:24:17.481732 [ 38666 ] {2db93657-4c33-4b9d-8817-653f9706a27c} <Error> executeQuery: Code: 517. DB::Exception: Metadata on replica is not up to date with common metadata in Zookeeper. Cannot alter. (CANNOT_ASSIGN_ALTER) (version 21.9.2.17 (official build)) (from 0.0.0.0:0) (in query: /* ddl_entry=query-0000000482 */ ALTER TABLE events_db.events_local_tables MODIFY COLUMN `server_port` UInt16), Stack trace (when copying this message, always include the lines below):
2021.09.20 20:24:17.482099 [ 38666 ] {2db93657-4c33-4b9d-8817-653f9706a27c} <Error> DDLWorker: Query ALTER TABLE events_db.events_local_tables MODIFY COLUMN `server_port` UInt16 wasn't finished successfully: Code: 517. DB::Exception: Metadata on replica is not up to date with common metadata in Zookeeper. Cannot alter. (CANNOT_ASSIGN_ALTER), Stack trace (when copying this message, always include the lines below):
2021.09.20 20:24:18.290940 [ 38517 ] {806f2936-b668-41aa-ab7c-16c485393b17} <Error> executeQuery: Code: 341. DB::Exception: There was an error on [10.120.1.117:9000]: Cannot execute replicated DDL query, maximum retries exceeded. (UNFINISHED) (version 21.9.2.17 (official build)) (from 10.120.1.122:54962) (in query:  /*TABIX_QUERY_ID_uUtFccK4*/ Alter table events_db.events_local_tables ON cluster click_cluster modify COLUMN server_port `UInt16` ), Stack trace (when copying this message, always include the lines below):

如果有人理解这些日志,请告诉我们在分布式中更改列类型的直接流程是什么tables

不幸的是,它没有记录在案,但如果您将多个更改发送到不同的副本(因为您在集群上使用),这是预期的行为

On running these queries one by one,
Alter table events_db.events_local_tables ON cluster click_cluster modify COLUMN client_port `UInt16`
Alter table events_db.events_local_tables ON cluster click_cluster modify COLUMN server_port `UInt16`

需要等到 所有副本 的第一个更改完成!!!!在发送下一个之前。

或者在一个命令中发送所有改变

Alter table events_db.events_local_tables ON cluster click_cluster 
   modify COLUMN client_port `UInt16`,
   modify COLUMN server_port `UInt16`;