github-actions[bot] commented on code in PR #32346: URL: https://github.com/apache/doris/pull/32346#discussion_r1528104058
########## be/src/runtime/query_context.h: ########## @@ -107,6 +107,13 @@ class QueryContext { void set_ready_to_execute(bool is_cancelled); [[nodiscard]] bool is_cancelled() const { return _is_cancelled.load(); } + + void cancel_all_pipeline_context(const PPlanFragmentCancelReason& reason, + const std::string& msg); + Status cancel_pipeline_context(const int fragment_id, const PPlanFragmentCancelReason& reason, Review Comment: warning: parameter 'fragment_id' is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions [readability-avoid-const-params-in-decls] ```suggestion Status cancel_pipeline_context(int fragment_id, const PPlanFragmentCancelReason& reason, ``` ########## be/src/runtime/query_context.cpp: ########## @@ -162,17 +166,48 @@ bool QueryContext::cancel(bool v, std::string msg, Status new_status, int fragme set_ready_to_execute(true); { - std::lock_guard<std::mutex> plock(pipeline_lock); - for (auto& ctx : fragment_id_to_pipeline_ctx) { - if (fragment_id == ctx.first) { + std::lock_guard<std::mutex> lock(_pipeline_map_write_lock); + for (auto& [f_id, f_context] : _fragment_id_to_pipeline_ctx) { + if (fragment_id == f_id) { continue; } - ctx.second->cancel(PPlanFragmentCancelReason::INTERNAL_ERROR, msg); + if (auto pipeline_ctx = f_context.lock()) { + pipeline_ctx->cancel(PPlanFragmentCancelReason::INTERNAL_ERROR, msg); + } } } return true; } +void QueryContext::cancel_all_pipeline_context(const PPlanFragmentCancelReason& reason, + const std::string& msg) { + std::lock_guard<std::mutex> lock(_pipeline_map_write_lock); + for (auto& [f_id, f_context] : _fragment_id_to_pipeline_ctx) { + if (auto pipeline_ctx = f_context.lock()) { + pipeline_ctx->cancel(reason, msg); + } + } +} + +Status QueryContext::cancel_pipeline_context(const int fragment_id, Review Comment: warning: method 'cancel_pipeline_context' can be made static [readability-convert-member-functions-to-static] ```suggestion static Status QueryContext::cancel_pipeline_context(const int fragment_id, ``` ########## be/src/runtime/query_context.h: ########## @@ -107,6 +107,13 @@ void set_ready_to_execute(bool is_cancelled); [[nodiscard]] bool is_cancelled() const { return _is_cancelled.load(); } + + void cancel_all_pipeline_context(const PPlanFragmentCancelReason& reason, + const std::string& msg); + Status cancel_pipeline_context(const int fragment_id, const PPlanFragmentCancelReason& reason, + const std::string& msg); + void set_pipeline_context(const int fragment_id, Review Comment: warning: parameter 'fragment_id' is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions [readability-avoid-const-params-in-decls] ```suggestion void set_pipeline_context(int fragment_id, ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org