Merge pull request #40720 from ClickHouse/fix_benign_race

Fix benign race in database replicated worker
This commit is contained in:
alesapin 2022-08-29 11:13:07 +02:00 committed by GitHub
commit 4ed375ca5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -133,10 +133,10 @@ bool DatabaseReplicatedDDLWorker::waitForReplicaToProcessAllEntries(UInt64 timeo
return true;
auto max_log = DDLTask::getLogEntryName(max_log_ptr);
LOG_TRACE(log, "Waiting for worker thread to process all entries before {}, current task is {}", max_log, current_task);
{
std::unique_lock lock{mutex};
LOG_TRACE(log, "Waiting for worker thread to process all entries before {}, current task is {}", max_log, current_task);
bool processed = wait_current_task_change.wait_for(lock, std::chrono::milliseconds(timeout_ms), [&]()
{
return zookeeper->expired() || current_task == max_log || stop_flag;
@ -146,8 +146,6 @@ bool DatabaseReplicatedDDLWorker::waitForReplicaToProcessAllEntries(UInt64 timeo
return false;
}
LOG_TRACE(log, "Waiting for worker thread to process all entries before {}, current task is {}", max_log, current_task);
/// Lets now wait for max_log_ptr to be processed
Coordination::Stat stat;
auto event_ptr = std::make_shared<Poco::Event>();