当发生此错误时,表显示为只读,并且错误指出部分重叠。您可以在日志中或通过以下方式查看错误:
SELECT *
FROM system.replicas
WHERE is_readonly = 1
错误消息如下所示:
Code: 49. DB::Exception: Part XXXXX intersects previous part YYYYY. It is a bug or a result of manual intervention in the ZooKeeper data. (LOGICAL_ERROR) (version 21.12.4.1 (official build))
错误原因
此错误可能是由 mergeSelectingTask
和队列重新初始化之间的竞争条件引起的。
解决方案
在所有副本上执行以下查询
DETACH TABLE table_name; -- Required for DROP REPLICA
SYSTEM DROP REPLICA 'replica_name' FROM ZK PATH '/table_path_in_zk/'; -- It will remove everything from /table_path_in_zk
ATTACH TABLE table_name; -- Table will be in readonly mode, because there is no metadata in ZK
然后在所有副本上执行以下操作
SYSTEM RESTORE REPLICA table_name; -- It will detach all partitions, re-create metadata in ZK (like it's new empty table), and then attach all partitions back
SYSTEM SYNC REPLICA table_name; -- Wait for replicas to synchronize parts. Also it's recommended to check `system.detached_parts` on all replicas after recovery is finished.
提示
您应该升级到最新版本的 ClickHouse
其他资源
相关的 PR 和 GitHub 问题
- ClickHouse/ClickHouse#34096
- ClickHouse/ClickHouse#30651
- ClickHouse/ClickHouse#31060
- ClickHouse/ClickHouse#35863
受影响的版本
ClickHouse v 22.12 及更早版本