mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 09:32:06 +00:00
Merge pull request #61105 from ClickHouse/fix_rdb_active
Fix removing is_active node after re-creation
This commit is contained in:
commit
2be2ca4605
@ -75,10 +75,9 @@ void DatabaseReplicatedDDLWorker::initializeReplication()
|
||||
String active_path = fs::path(database->replica_path) / "active";
|
||||
String active_id = toString(ServerUUID::get());
|
||||
zookeeper->deleteEphemeralNodeIfContentMatches(active_path, active_id);
|
||||
zookeeper->create(active_path, active_id, zkutil::CreateMode::Ephemeral);
|
||||
if (active_node_holder)
|
||||
active_node_holder->setAlreadyRemoved();
|
||||
active_node_holder.reset();
|
||||
active_node_holder_zookeeper = zookeeper;
|
||||
active_node_holder = zkutil::EphemeralNodeHolder::existing(active_path, *active_node_holder_zookeeper);
|
||||
|
||||
String log_ptr_str = zookeeper->get(database->replica_path + "/log_ptr");
|
||||
UInt32 our_log_ptr = parse<UInt32>(log_ptr_str);
|
||||
@ -127,9 +126,15 @@ void DatabaseReplicatedDDLWorker::initializeReplication()
|
||||
initializeLogPointer(log_entry_name);
|
||||
}
|
||||
|
||||
{
|
||||
std::lock_guard lock{database->metadata_mutex};
|
||||
if (!database->checkDigestValid(context, false))
|
||||
throw Exception(ErrorCodes::LOGICAL_ERROR, "Inconsistent database metadata after reconnection to ZooKeeper");
|
||||
}
|
||||
|
||||
zookeeper->create(active_path, active_id, zkutil::CreateMode::Ephemeral);
|
||||
active_node_holder_zookeeper = zookeeper;
|
||||
active_node_holder = zkutil::EphemeralNodeHolder::existing(active_path, *active_node_holder_zookeeper);
|
||||
}
|
||||
|
||||
String DatabaseReplicatedDDLWorker::enqueueQuery(DDLLogEntry & entry)
|
||||
|
@ -1138,6 +1138,10 @@ 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)
|
||||
|
Loading…
Reference in New Issue
Block a user