Update StorageReplicatedMergeTree.cpp

This commit is contained in:
Alexander Tokmakov 2022-11-21 21:52:48 +03:00 committed by GitHub
parent 581e57be9f
commit a7efdd7f4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7645,7 +7645,15 @@ void StorageReplicatedMergeTree::createTableSharedID() const
return;
}
auto zookeeper = getZooKeeper();
/// We may call getTableSharedID when table is shut down. If exception happen, restarting thread will be already turned
/// off and nobody will reconnect our zookeeper connection. In this case we use zookeeper connection from
/// context.
ZooKeeperPtr zookeeper;
if (shutdown_called.load())
zookeeper = getZooKeeperIfTableShutDown();
else
zookeeper = getZooKeeper();
String zookeeper_table_id_path = fs::path(zookeeper_path) / "table_shared_id";
String id;
if (!zookeeper->tryGet(zookeeper_table_id_path, id))