Merge pull request #10784 from ClickHouse/fix-queue-race-condition

Fix race condition in ReplicatedMergeTreeQueue
This commit is contained in:
alexey-milovidov 2020-05-10 08:18:08 +03:00 committed by GitHub
commit 961603b111
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2954,6 +2954,7 @@ void StorageReplicatedMergeTree::startup()
/// If we don't separate create/start steps, race condition will happen
/// between the assignment of queue_task_handle and queueTask that use the queue_task_handle.
{
auto lock = queue.lockQueue();
auto & pool = global_context.getBackgroundPool();
queue_task_handle = pool.createTask([this] { return queueTask(); });
pool.startTask(queue_task_handle);
@ -2993,7 +2994,6 @@ void StorageReplicatedMergeTree::shutdown()
queue_task_handle.reset();
}
if (move_parts_task_handle)
global_context.getBackgroundMovePool().removeTask(move_parts_task_handle);
move_parts_task_handle.reset();