mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 07:31:57 +00:00
Merge pull request #66991 from ClickHouse/fix-database-replicated-ddl-worker-data-race
[CI Fest] Fix data race in DatabaseReplicatedDDLWorker
This commit is contained in:
commit
00c1b89aae
@ -559,8 +559,11 @@ void DatabaseReplicated::createEmptyLogEntry(const ZooKeeperPtr & current_zookee
|
||||
|
||||
bool DatabaseReplicated::waitForReplicaToProcessAllEntries(UInt64 timeout_ms)
|
||||
{
|
||||
if (!ddl_worker || is_probably_dropped)
|
||||
return false;
|
||||
{
|
||||
std::lock_guard lock{ddl_worker_mutex};
|
||||
if (!ddl_worker || is_probably_dropped)
|
||||
return false;
|
||||
}
|
||||
return ddl_worker->waitForReplicaToProcessAllEntries(timeout_ms);
|
||||
}
|
||||
|
||||
@ -641,7 +644,10 @@ LoadTaskPtr DatabaseReplicated::startupDatabaseAsync(AsyncLoader & async_loader,
|
||||
if (is_probably_dropped)
|
||||
return;
|
||||
|
||||
ddl_worker = std::make_unique<DatabaseReplicatedDDLWorker>(this, getContext());
|
||||
{
|
||||
std::lock_guard lock{ddl_worker_mutex};
|
||||
ddl_worker = std::make_unique<DatabaseReplicatedDDLWorker>(this, getContext());
|
||||
}
|
||||
ddl_worker->startup();
|
||||
ddl_worker_initialized = true;
|
||||
});
|
||||
@ -1516,6 +1522,7 @@ void DatabaseReplicated::renameDatabase(ContextPtr query_context, const String &
|
||||
|
||||
void DatabaseReplicated::stopReplication()
|
||||
{
|
||||
std::lock_guard lock{ddl_worker_mutex};
|
||||
if (ddl_worker)
|
||||
ddl_worker->shutdown();
|
||||
}
|
||||
|
@ -155,6 +155,7 @@ private:
|
||||
std::atomic_bool is_recovering = false;
|
||||
std::atomic_bool ddl_worker_initialized = false;
|
||||
std::unique_ptr<DatabaseReplicatedDDLWorker> ddl_worker;
|
||||
std::mutex ddl_worker_mutex;
|
||||
UInt32 max_log_ptr_at_creation = 0;
|
||||
|
||||
/// Usually operation with metadata are single-threaded because of the way replication works,
|
||||
|
Loading…
Reference in New Issue
Block a user