Fix missing thread accounting for insert_distributed_sync=1

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
This commit is contained in:
Azat Khuzhin 2023-10-09 15:41:52 +02:00
parent 807cf893e8
commit 5d2a97106c

View File

@ -553,8 +553,15 @@ void DistributedSink::onFinish()
{
if (job.executor)
{
pool->scheduleOrThrowOnError([&job]()
pool->scheduleOrThrowOnError([&job, thread_group = CurrentThread::getGroup()]()
{
SCOPE_EXIT_SAFE(
if (thread_group)
CurrentThread::detachFromGroupIfNotDetached();
);
if (thread_group)
CurrentThread::attachToGroupIfDetached(thread_group);
job.executor->finish();
});
}