Skip to content

Commit

Permalink
Remove inconsistent parts in zookeeper
Browse files Browse the repository at this point in the history
  • Loading branch information
amosbird committed Dec 9, 2021
1 parent e0a8c5a commit 06bdd35
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Storages/StorageReplicatedMergeTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1190,8 +1190,13 @@ void StorageReplicatedMergeTree::checkParts(bool skip_sanity_checks)
/// Which parts should be taken from other replicas.
Strings parts_to_fetch;

/// Missing parts which should be cleared from zookeeper. It's likely because we clean old parts during shutdown.
Strings parts_to_remove_from_zk;

for (const String & missing_name : expected_parts)
if (!getActiveContainingPart(missing_name))
if (getActiveContainingPart(missing_name))
parts_to_remove_from_zk.push_back(missing_name);
else
parts_to_fetch.push_back(missing_name);

/** To check the adequacy, for the parts that are in the FS, but not in ZK, we will only consider not the most recent parts.
Expand Down Expand Up @@ -1260,6 +1265,8 @@ void StorageReplicatedMergeTree::checkParts(bool skip_sanity_checks)
parts_to_fetch.size(), parts_to_fetch_blocks);
}

tryRemovePartsFromZooKeeperWithRetries(parts_to_remove_from_zk);

/// Add to the queue jobs to pick up the missing parts from other replicas and remove from ZK the information that we have them.
queue.setBrokenPartsToEnqueueFetchesOnLoading(std::move(parts_to_fetch));

Expand Down

0 comments on commit 06bdd35

Please sign in to comment.