Do not allow table to be attached if there already is an active replica path

This commit is contained in:
Arthur Passos 2024-03-25 11:19:12 -03:00
parent 15896ecaf6
commit 6c56c0c89e

View File

@ -399,6 +399,11 @@ StorageReplicatedMergeTree::StorageReplicatedMergeTree(
{ {
try 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")) if (current_zookeeper && current_zookeeper->exists(replica_path + "/host"))
{ {
/// Check it earlier if we can (we don't want incompatible version to start). /// Check it earlier if we can (we don't want incompatible version to start).