From a5ed26c393623d4f7649c5b260e419e122b4b847 Mon Sep 17 00:00:00 2001 From: Nikolai Kochetov Date: Tue, 27 Jul 2021 11:55:19 +0300 Subject: [PATCH] Flush LazyOutputFormat on query cancel. --- src/Processors/Executors/PullingAsyncPipelineExecutor.cpp | 5 ++--- src/Processors/Formats/LazyOutputFormat.h | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Processors/Executors/PullingAsyncPipelineExecutor.cpp b/src/Processors/Executors/PullingAsyncPipelineExecutor.cpp index ca5f4cc290f..8ecbe75af3a 100644 --- a/src/Processors/Executors/PullingAsyncPipelineExecutor.cpp +++ b/src/Processors/Executors/PullingAsyncPipelineExecutor.cpp @@ -174,9 +174,8 @@ void PullingAsyncPipelineExecutor::cancel() if (data && !data->is_finished && data->executor) data->executor->cancel(); - /// Finish lazy format. Otherwise thread.join() may hung. - if (lazy_format && !lazy_format->isFinished()) - lazy_format->finish(); + /// The following code is needed to rethrow exception from PipelineExecutor. + /// It could have been thrown from pull(), but we will not likely call it again. /// Join thread here to wait for possible exception. if (data && data->thread.joinable()) diff --git a/src/Processors/Formats/LazyOutputFormat.h b/src/Processors/Formats/LazyOutputFormat.h index 15ea5022f82..c6be0adb347 100644 --- a/src/Processors/Formats/LazyOutputFormat.h +++ b/src/Processors/Formats/LazyOutputFormat.h @@ -29,7 +29,7 @@ public: void setRowsBeforeLimit(size_t rows_before_limit) override; - void finish() + void onCancel() override { finished_processing = true; /// Clear queue in case if somebody is waiting lazy_format to push.