From e858dae1872bfac6821c5bcdcfa7325228e0284c Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Wed, 3 Mar 2021 23:41:24 +0300 Subject: [PATCH] Fix SIGSEGV for distributed queries on failures Since after pull(), cancel() will be called, and this will lead to SIGSEGV, since there is no exception, but has_exception was not reseted in pull() --- src/Processors/Executors/PullingAsyncPipelineExecutor.cpp | 3 +-- .../0_stateless/01752_distributed_query_sigsegv.reference | 0 .../0_stateless/01752_distributed_query_sigsegv.sql | 8 ++++++++ 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 tests/queries/0_stateless/01752_distributed_query_sigsegv.reference create mode 100644 tests/queries/0_stateless/01752_distributed_query_sigsegv.sql diff --git a/src/Processors/Executors/PullingAsyncPipelineExecutor.cpp b/src/Processors/Executors/PullingAsyncPipelineExecutor.cpp index c975153d317..f1626414375 100644 --- a/src/Processors/Executors/PullingAsyncPipelineExecutor.cpp +++ b/src/Processors/Executors/PullingAsyncPipelineExecutor.cpp @@ -110,8 +110,7 @@ bool PullingAsyncPipelineExecutor::pull(Chunk & chunk, uint64_t milliseconds) data->thread = ThreadFromGlobalPool(std::move(func)); } - if (data->has_exception) - std::rethrow_exception(std::move(data->exception)); + data->rethrowExceptionIfHas(); bool is_execution_finished = lazy_format ? lazy_format->isFinished() : data->is_finished.load(); diff --git a/tests/queries/0_stateless/01752_distributed_query_sigsegv.reference b/tests/queries/0_stateless/01752_distributed_query_sigsegv.reference new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/queries/0_stateless/01752_distributed_query_sigsegv.sql b/tests/queries/0_stateless/01752_distributed_query_sigsegv.sql new file mode 100644 index 00000000000..a6936aec913 --- /dev/null +++ b/tests/queries/0_stateless/01752_distributed_query_sigsegv.sql @@ -0,0 +1,8 @@ +-- this is enough to trigger the regression +SELECT throwIf(dummy = 0) FROM remote('127.1', system.one); -- { serverError 395 } + +-- these are just in case +SELECT throwIf(dummy = 0) FROM remote('127.{1,2}', system.one); -- { serverError 395 } +SELECT throwIf(dummy = 0) FROM remote('127.{1,2}', system.one) SETTINGS prefer_localhost_replica=0; -- { serverError 395 } +SELECT throwIf(dummy = 0) FROM remote('127.{1,2}', system.one) SETTINGS prefer_localhost_replica=0, distributed_group_by_no_merge=1; -- { serverError 395 } +SELECT throwIf(dummy = 0) FROM remote('127.{1,2}', system.one) SETTINGS prefer_localhost_replica=0, distributed_group_by_no_merge=2; -- { serverError 395 }