mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Merge pull request #4399 from yandex/better-replica-repair
Better replica repair
This commit is contained in:
commit
ed3a8a66a2
@ -523,6 +523,22 @@ int32_t ZooKeeper::tryMulti(const Coordination::Requests & requests, Coordinatio
|
||||
}
|
||||
|
||||
|
||||
void ZooKeeper::removeChildren(const std::string & path)
|
||||
{
|
||||
Strings children = getChildren(path);
|
||||
while (!children.empty())
|
||||
{
|
||||
Coordination::Requests ops;
|
||||
for (size_t i = 0; i < MULTI_BATCH_SIZE && !children.empty(); ++i)
|
||||
{
|
||||
ops.emplace_back(makeRemoveRequest(path + "/" + children.back(), -1));
|
||||
children.pop_back();
|
||||
}
|
||||
multi(ops);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ZooKeeper::removeChildrenRecursive(const std::string & path)
|
||||
{
|
||||
Strings children = getChildren(path);
|
||||
|
@ -177,6 +177,9 @@ public:
|
||||
/// result would be the same as for the single call.
|
||||
void tryRemoveRecursive(const std::string & path);
|
||||
|
||||
/// Remove all children nodes (non recursive).
|
||||
void removeChildren(const std::string & path);
|
||||
|
||||
/// Wait for the node to disappear or return immediately if it doesn't exist.
|
||||
void waitForDisappear(const std::string & path);
|
||||
|
||||
|
@ -2036,6 +2036,9 @@ void StorageReplicatedMergeTree::cloneReplicaIfNeeded(zkutil::ZooKeeperPtr zooke
|
||||
if (source_replica.empty())
|
||||
throw Exception("All replicas are lost", ErrorCodes::ALL_REPLICAS_LOST);
|
||||
|
||||
/// Clear obsolete queue that we no longer need.
|
||||
zookeeper->removeChildren(replica_path + "/queue");
|
||||
|
||||
/// Will do repair from the selected replica.
|
||||
cloneReplica(source_replica, source_is_lost_stat, zookeeper);
|
||||
/// If repair fails to whatever reason, the exception is thrown, is_lost will remain "1" and the replica will be repaired later.
|
||||
|
Loading…
Reference in New Issue
Block a user