fix possible deadlock

This commit is contained in:
serxa 2023-02-14 19:37:09 +00:00
parent df6b4c4372
commit a7bbf02bac
2 changed files with 14 additions and 2 deletions

View File

@ -3825,9 +3825,9 @@ void Context::initializeBackgroundExecutorsIfNeeded()
"MergeMutate",
/*max_threads_count*/background_pool_size,
/*max_tasks_count*/background_pool_size * background_merges_mutations_concurrency_ratio,
CurrentMetrics::BackgroundMergesAndMutationsPoolTask
CurrentMetrics::BackgroundMergesAndMutationsPoolTask,
background_merges_mutations_scheduling_policy
);
shared->merge_mutate_executor->updateSchedulingPolicy(background_merges_mutations_scheduling_policy);
LOG_INFO(shared->log, "Initialized background executor for merges and mutations with num_threads={}, num_tasks={}, scheduling_policy={}",
background_pool_size, background_pool_size * background_merges_mutations_concurrency_ratio, background_merges_mutations_scheduling_policy);

View File

@ -267,6 +267,18 @@ public:
pool.scheduleOrThrowOnError([this] { threadFunction(); });
}
MergeTreeBackgroundExecutor(
String name_,
size_t threads_count_,
size_t max_tasks_count_,
CurrentMetrics::Metric metric_,
std::string_view policy)
requires requires(Queue queue) { queue.updatePolicy(policy); } // Because we use explicit template instantiation
: MergeTreeBackgroundExecutor(name_, threads_count_, max_tasks_count_, metric_)
{
pending.updatePolicy(policy);
}
~MergeTreeBackgroundExecutor()
{
wait();