Skip to content

Commit

Permalink
branch-3.0: [refactor](cancel) Reduce lock scope in cancel worker apa…
Browse files Browse the repository at this point in the history
…che#42520 (apache#44837)

Cherry-picked from apache#42520

Co-authored-by: Gabriel <[email protected]>
  • Loading branch information
github-actions[bot] and Gabriel39 authored Dec 2, 2024
1 parent 95aacda commit 7af87cc
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion be/src/runtime/fragment_mgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -935,11 +935,20 @@ void FragmentMgr::cancel_worker() {
running_queries_on_all_fes.clear();
}

std::vector<std::shared_ptr<pipeline::PipelineFragmentContext>> ctx;
{
std::lock_guard<std::mutex> lock(_lock);
ctx.reserve(_pipeline_map.size());
for (auto& pipeline_itr : _pipeline_map) {
pipeline_itr.second->clear_finished_tasks();
ctx.push_back(pipeline_itr.second);
}
}
for (auto& c : ctx) {
c->clear_finished_tasks();
}

{
std::lock_guard<std::mutex> lock(_lock);
for (auto it = _query_ctx_map.begin(); it != _query_ctx_map.end();) {
if (auto q_ctx = it->second.lock()) {
if (q_ctx->is_timeout(now)) {
Expand Down

0 comments on commit 7af87cc

Please sign in to comment.