#122744·ClickHouse

删除副本时,会出现并发变异失败,错误信息为"部分 ... 具有空的头部,且没有列和校验和"

作者: PedroTadim创建于 2026年9月28日更新于 2026年9月29日
标签bugcomp-replication

dropReplica removes the parts subtree with probably_flat = true (StorageReplicatedMergeTree.cpp, "Then try to remove paths that are known to be flat"):

cpp
flat_nodes.emplace_back("parts");
...
bool removed_quickly = zookeeper->tryRemoveChildrenRecursive(fs::path(remote_replica_path) / node, /* probably flat */ true);

That assumption only holds for the minimalistic header. With the old format, the bulk multi fails with ZNOTEMPTY, and tryRemoveChildrenRecursive falls back to two separate calls (ZooKeeper.cpp:1183-1191):

cpp
if (res.error == Coordination::Error::ZNOTEMPTY)
{
    if (probably_flat)
    {
        /// It actually has children, let's remove them
        tryRemoveChildrenRecursive(batch[i]);
        tryRemove(batch[i]);
    }
    continue;
}

Between those two lines, the part node exists with no columns and no checksums. A concurrent reader lands in the branch that is written as unreachable (StorageReplicatedMergeTree.cpp:2303-2320):

cpp
if (zookeeper->tryGet(fs::path(current_part_path) / "columns", columns_str) &&
    zookeeper->tryGet(fs::path(current_part_path) / "checksums", checksums_str))
{
    replica_part_header =
…

内容来源: ClickHouse/ClickHouse