From 6c56c0c89ed63c35bf524071852eba066de917da Mon Sep 17 00:00:00 2001 From: Arthur Passos Date: Mon, 25 Mar 2024 11:19:12 -0300 Subject: [PATCH] Do not allow table to be attached if there already is an active replica path --- src/Storages/StorageReplicatedMergeTree.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Storages/StorageReplicatedMergeTree.cpp b/src/Storages/StorageReplicatedMergeTree.cpp index c41403e312b..8c711ffd25f 100644 --- a/src/Storages/StorageReplicatedMergeTree.cpp +++ b/src/Storages/StorageReplicatedMergeTree.cpp @@ -399,6 +399,11 @@ StorageReplicatedMergeTree::StorageReplicatedMergeTree( { try { + if (LoadingStrictnessLevel::ATTACH == mode && current_zookeeper && current_zookeeper->exists(replica_path + "/is_active")) + { + throw Exception(ErrorCodes::REPLICA_ALREADY_EXISTS, "There already is an active replica with this replica path {}", replica_path); + } + if (current_zookeeper && current_zookeeper->exists(replica_path + "/host")) { /// Check it earlier if we can (we don't want incompatible version to start).