mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 09:32:01 +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)
|
bool DatabaseReplicated::waitForReplicaToProcessAllEntries(UInt64 timeout_ms)
|
||||||
{
|
{
|
||||||
|
{
|
||||||
|
std::lock_guard lock{ddl_worker_mutex};
|
||||||
if (!ddl_worker || is_probably_dropped)
|
if (!ddl_worker || is_probably_dropped)
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
return ddl_worker->waitForReplicaToProcessAllEntries(timeout_ms);
|
return ddl_worker->waitForReplicaToProcessAllEntries(timeout_ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -641,7 +644,10 @@ LoadTaskPtr DatabaseReplicated::startupDatabaseAsync(AsyncLoader & async_loader,
|
|||||||
if (is_probably_dropped)
|
if (is_probably_dropped)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
{
|
||||||
|
std::lock_guard lock{ddl_worker_mutex};
|
||||||
ddl_worker = std::make_unique<DatabaseReplicatedDDLWorker>(this, getContext());
|
ddl_worker = std::make_unique<DatabaseReplicatedDDLWorker>(this, getContext());
|
||||||
|
}
|
||||||
ddl_worker->startup();
|
ddl_worker->startup();
|
||||||
ddl_worker_initialized = true;
|
ddl_worker_initialized = true;
|
||||||
});
|
});
|
||||||
@ -1516,6 +1522,7 @@ void DatabaseReplicated::renameDatabase(ContextPtr query_context, const String &
|
|||||||
|
|
||||||
void DatabaseReplicated::stopReplication()
|
void DatabaseReplicated::stopReplication()
|
||||||
{
|
{
|
||||||
|
std::lock_guard lock{ddl_worker_mutex};
|
||||||
if (ddl_worker)
|
if (ddl_worker)
|
||||||
ddl_worker->shutdown();
|
ddl_worker->shutdown();
|
||||||
}
|
}
|
||||||
|
@ -155,6 +155,7 @@ private:
|
|||||||
std::atomic_bool is_recovering = false;
|
std::atomic_bool is_recovering = false;
|
||||||
std::atomic_bool ddl_worker_initialized = false;
|
std::atomic_bool ddl_worker_initialized = false;
|
||||||
std::unique_ptr<DatabaseReplicatedDDLWorker> ddl_worker;
|
std::unique_ptr<DatabaseReplicatedDDLWorker> ddl_worker;
|
||||||
|
std::mutex ddl_worker_mutex;
|
||||||
UInt32 max_log_ptr_at_creation = 0;
|
UInt32 max_log_ptr_at_creation = 0;
|
||||||
|
|
||||||
/// Usually operation with metadata are single-threaded because of the way replication works,
|
/// Usually operation with metadata are single-threaded because of the way replication works,
|
||||||
|
Loading…
Reference in New Issue
Block a user