Merge pull request #55392 from azat/dist-insert-threads-fix

Fix missing thread accounting for insert_distributed_sync=1
This commit is contained in:
robot-ch-test-poll4 2023-10-10 03:18:16 +02:00 committed by GitHub
commit 8609cd25fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 1 deletions

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

View File

@ -0,0 +1,17 @@
#!/usr/bin/env bash
CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=../shell_config.sh
. "$CUR_DIR"/../shell_config.sh
$CLICKHOUSE_CLIENT -nm -q "
DROP TABLE IF EXISTS data;
DROP TABLE IF EXISTS data2;
DROP VIEW IF EXISTS mv1;
CREATE TABLE data (key Int32) ENGINE = Null;
CREATE TABLE data2 (key Int32) ENGINE = Null;
CREATE MATERIALIZED VIEW mv1 TO data2 AS SELECT * FROM data;
"
${CLICKHOUSE_CURL} -sS "${CLICKHOUSE_URL}" -d @- <<< "INSERT INTO FUNCTION remote('127.{1,2}', $CLICKHOUSE_DATABASE, data, rand()) SELECT * FROM numbers(1e5)"