Merge pull request #46709 from azat/bg-pool-no-query

BackgroundSchedulePool should not have any query context
This commit is contained in:
Alexey Milovidov 2023-02-23 10:24:46 +03:00 committed by GitHub
commit c0bc549e77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 0 additions and 35 deletions

View File

@ -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;

View File

@ -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();
};

View File

@ -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>

View File

@ -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>