mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 01:25:21 +00:00
Merge pull request #46709 from azat/bg-pool-no-query
BackgroundSchedulePool should not have any query context
This commit is contained in:
commit
c0bc549e77
@ -252,36 +252,10 @@ void BackgroundSchedulePool::cancelDelayedTask(const TaskInfoPtr & task, std::lo
|
||||
}
|
||||
|
||||
|
||||
scope_guard BackgroundSchedulePool::attachToThreadGroup()
|
||||
{
|
||||
scope_guard guard = [&]()
|
||||
{
|
||||
if (thread_group)
|
||||
CurrentThread::detachQueryIfNotDetached();
|
||||
};
|
||||
|
||||
std::lock_guard lock(delayed_tasks_mutex);
|
||||
|
||||
if (thread_group)
|
||||
{
|
||||
/// Put all threads to one thread pool
|
||||
CurrentThread::attachTo(thread_group);
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentThread::initializeQuery();
|
||||
thread_group = CurrentThread::getGroup();
|
||||
}
|
||||
return guard;
|
||||
}
|
||||
|
||||
|
||||
void BackgroundSchedulePool::threadFunction()
|
||||
{
|
||||
setThreadName(thread_name.c_str());
|
||||
|
||||
auto detach_thread_guard = attachToThreadGroup();
|
||||
|
||||
while (!shutdown)
|
||||
{
|
||||
TaskInfoPtr task;
|
||||
@ -311,8 +285,6 @@ void BackgroundSchedulePool::delayExecutionThreadFunction()
|
||||
{
|
||||
setThreadName((thread_name + "/D").c_str());
|
||||
|
||||
auto detach_thread_guard = attachToThreadGroup();
|
||||
|
||||
while (!shutdown)
|
||||
{
|
||||
TaskInfoPtr task;
|
||||
|
@ -90,13 +90,8 @@ private:
|
||||
/// Tasks ordered by scheduled time.
|
||||
DelayedTasks delayed_tasks;
|
||||
|
||||
/// Thread group used for profiling purposes
|
||||
ThreadGroupStatusPtr thread_group;
|
||||
|
||||
CurrentMetrics::Metric tasks_metric;
|
||||
std::string thread_name;
|
||||
|
||||
[[nodiscard]] scope_guard attachToThreadGroup();
|
||||
};
|
||||
|
||||
|
||||
|
@ -3,7 +3,6 @@
|
||||
#include <condition_variable>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <Core/BackgroundSchedulePool.h>
|
||||
#include <Functions/FunctionsLogical.h>
|
||||
#include <Interpreters/Context.h>
|
||||
#include <Interpreters/ExpressionActions.h>
|
||||
|
@ -4,7 +4,6 @@
|
||||
#include <Interpreters/ExpressionActionsSettings.h>
|
||||
#include <Storages/MergeTree/MergeTreeReadPool.h>
|
||||
#include <Storages/MergeTree/MergeTreeIOSettings.h>
|
||||
#include <Core/BackgroundSchedulePool.h>
|
||||
#include <IO/AsyncReadCounters.h>
|
||||
#include <queue>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user