diff --git a/src/Storages/StorageReplicatedMergeTree.cpp b/src/Storages/StorageReplicatedMergeTree.cpp index 6a9e0c4c1be..b75035efcee 100644 --- a/src/Storages/StorageReplicatedMergeTree.cpp +++ b/src/Storages/StorageReplicatedMergeTree.cpp @@ -1224,7 +1224,7 @@ bool StorageReplicatedMergeTree::dropReplica( if (zookeeper->expired()) throw Exception(ErrorCodes::TABLE_WAS_NOT_DROPPED, "Table was not dropped because ZooKeeper session has expired."); - String zookeeper_path = zookeeper_info.path; + const String & zookeeper_path = zookeeper_info.path; auto remote_replica_path = zookeeper_path + "/replicas/" + zookeeper_info.replica_name; LOG_INFO(logger, "Removing replica {}, marking it as lost", remote_replica_path); @@ -1362,7 +1362,7 @@ bool StorageReplicatedMergeTree::dropReplica(const String & drop_replica, Logger bool StorageReplicatedMergeTree::removeTableNodesFromZooKeeper(zkutil::ZooKeeperPtr zookeeper, const TableZnodeInfo & zookeeper_info2, const zkutil::EphemeralNodeHolder::Ptr & metadata_drop_lock, LoggerPtr logger) { - String zookeeper_path = zookeeper_info2.path; + const String & zookeeper_path = zookeeper_info2.path; bool completely_removed = false; /// NOTE /block_numbers/ actually is not flat, because /block_numbers// may have ephemeral children, @@ -1430,15 +1430,15 @@ bool StorageReplicatedMergeTree::removeTableNodesFromZooKeeper(zkutil::ZooKeeper metadata_drop_lock->setAlreadyRemoved(); completely_removed = true; LOG_INFO(logger, "Table {} was successfully removed from ZooKeeper", zookeeper_path); - } - try - { - zookeeper_info2.dropAncestorZnodesIfNeeded(zookeeper); - } - catch (...) - { - LOG_WARNING(logger, "Failed to drop ancestor znodes {} - {} after dropping table: {}", zookeeper_info2.path_prefix_for_drop, zookeeper_info2.path, getCurrentExceptionMessage(false)); + try + { + zookeeper_info2.dropAncestorZnodesIfNeeded(zookeeper); + } + catch (...) + { + LOG_WARNING(logger, "Failed to drop ancestor znodes {} - {} after dropping table: {}", zookeeper_info2.path_prefix_for_drop, zookeeper_info2.path, getCurrentExceptionMessage(false)); + } } return completely_removed;