Skip to content

Commit

Permalink
[fix](cancel) Fix cancel failure (#48751)
Browse files Browse the repository at this point in the history
### What problem does this PR solve?

If a query is canceled before fragment contexts are prepared, no
fragment context will be found. So we should set execution ready to
ensure tasks will not be blocked.
  • Loading branch information
Gabriel39 authored Mar 7, 2025
1 parent 3f684f2 commit 48e3a73
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 0 additions & 1 deletion be/src/pipeline/pipeline_x/pipeline_x_task.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ class PipelineXTask : public PipelineTask {
int task_id() const { return _index; };

void clear_blocking_state() override {
_state->get_query_ctx()->get_execution_dependency()->set_always_ready();
// We use a lock to assure all dependencies are not deconstructed here.
std::unique_lock<std::mutex> lc(_dependency_lock);
if (!_finished) {
Expand Down
2 changes: 2 additions & 0 deletions be/src/runtime/query_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ void QueryContext::cancel(std::string msg, Status new_status, int fragment_id) {

void QueryContext::cancel_all_pipeline_context(const PPlanFragmentCancelReason& reason,
const std::string& msg) {
set_execution_dependency_ready();
std::vector<std::weak_ptr<pipeline::PipelineFragmentContext>> ctx_to_cancel;
{
std::lock_guard<std::mutex> lock(_pipeline_map_write_lock);
Expand All @@ -267,6 +268,7 @@ void QueryContext::cancel_all_pipeline_context(const PPlanFragmentCancelReason&
Status QueryContext::cancel_pipeline_context(const int fragment_id,
const PPlanFragmentCancelReason& reason,
const std::string& msg) {
set_execution_dependency_ready();
std::weak_ptr<pipeline::PipelineFragmentContext> ctx_to_cancel;
{
std::lock_guard<std::mutex> lock(_pipeline_map_write_lock);
Expand Down

0 comments on commit 48e3a73

Please sign in to comment.