From bc200ab993dc63d85a69999ccebb1d092c5e67ff Mon Sep 17 00:00:00 2001 From: Jerry Hu Date: Mon, 17 Jun 2024 16:25:28 +0800 Subject: [PATCH] [fix](be) return correct canceled status from scanner --- be/src/pipeline/exec/scan_operator.cpp | 2 +- be/src/runtime/runtime_state.cpp | 10 +++++++++- be/src/vec/exec/scan/scanner_context.cpp | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/be/src/pipeline/exec/scan_operator.cpp b/be/src/pipeline/exec/scan_operator.cpp index ac115d438792e7..161a79fb7c1476 100644 --- a/be/src/pipeline/exec/scan_operator.cpp +++ b/be/src/pipeline/exec/scan_operator.cpp @@ -1461,7 +1461,7 @@ Status ScanOperatorX::get_block(RuntimeState* state, vectorized: if (local_state._scanner_ctx) { local_state._scanner_ctx->stop_scanners(state); } - return Status::Cancelled("Query cancelled in ScanOperator"); + return state->cancel_reason(); } if (local_state._eos) { diff --git a/be/src/runtime/runtime_state.cpp b/be/src/runtime/runtime_state.cpp index 6626ada034c951..137b5a84642ef1 100644 --- a/be/src/runtime/runtime_state.cpp +++ b/be/src/runtime/runtime_state.cpp @@ -345,7 +345,15 @@ bool RuntimeState::is_cancelled() const { } Status RuntimeState::cancel_reason() const { - return _exec_status.status(); + if (!_exec_status.ok()) { + return _exec_status.status(); + } + + if (_query_ctx) { + return _query_ctx->exec_status(); + } + + return Status::Cancelled("Query cancelled"); } const int64_t MAX_ERROR_NUM = 50; diff --git a/be/src/vec/exec/scan/scanner_context.cpp b/be/src/vec/exec/scan/scanner_context.cpp index 6f7c41ff9b40ea..e15ec015908eff 100644 --- a/be/src/vec/exec/scan/scanner_context.cpp +++ b/be/src/vec/exec/scan/scanner_context.cpp @@ -215,7 +215,7 @@ Status ScannerContext::get_block_from_queue(RuntimeState* state, vectorized::Blo bool* eos, int id) { if (state->is_cancelled()) { _set_scanner_done(); - return Status::Cancelled("Query cancelled in ScannerContext"); + return state->cancel_reason(); } std::unique_lock l(_transfer_lock);