ClickHouse 副本不同步

ClickHouse replica out of sync

我有一个由 3 个 ClickHouse 服务器组成的集群,其中 table 使用 ReplicatedMergeTree。其中两台服务器不同步,'system.replication_queue' 中的队列数不断增加。我可以在日志中看到这个错误。

Not executing log entry for part e87a3a2d13950a90846a513f435c2560_2428139_2436934_22 because source parts size (470.12 MiB) is greater than the current maximum (4.45 MiB).

如何增加源部件的大小?我在设置里没找到。

更新:

我看了源代码,它是根据可用资源自动计算的。我也收到这条消息

Not executing log entry for part de77ce6a2937ce543cd003eb289fdb7e_8097652_8107495_1904 because another log entry for the same part is being processed. This shouldn't happen often.

在日志中收到上述消息的服务器在插入时 CPU 使用率和延迟很高。

一旦我停止插入,复制队列就会被清除。

我找到了解决方案。发生这种情况是因为@vladimir

建议的“合并处理速度明显慢于插入”

我正在大批量插入数据,但这并不意味着 clickhouse 也会将数据存储在大文件中。 Clickhouse 存储数据基于

number of partitions * number of columns * (times 2 for every nullable column)

因此,即使对于单个大批量插入,也会创建多个文件。我通过删除分区键减少分区数量从而减少创建的文件数量解决了这个问题。