fix removing is_active node after re-creation

This commit is contained in:
Alexander Tokmakov 2024-03-08 17:12:31 +01:00
parent d93dd98b66
commit e2317477f7
2 changed files with 4 additions and 0 deletions

View File

@ -75,6 +75,8 @@ void DatabaseReplicatedDDLWorker::initializeReplication()
String active_path = fs::path(database->replica_path) / "active";
String active_id = toString(ServerUUID::get());
zookeeper->deleteEphemeralNodeIfContentMatches(active_path, active_id);
if (active_node_holder)
active_node_holder->setAlreadyRemoved();
zookeeper->create(active_path, active_id, zkutil::CreateMode::Ephemeral);
active_node_holder.reset();
active_node_holder_zookeeper = zookeeper;

View File

@ -1141,6 +1141,8 @@ def test_sync_replica(started_cluster):
dummy_node.query("SYSTEM SYNC DATABASE REPLICA test_sync_database")
assert "2\n" == main_node.query("SELECT sum(is_active) FROM system.clusters WHERE cluster='test_sync_database'")
assert dummy_node.query(
"SELECT count() FROM system.tables where database='test_sync_database'"
).strip() == str(number_of_tables)