This is an automated email from the ASF dual-hosted git repository.
gabriellee pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new ad91767bdb2 [refactor](cancel) Reduce lock scope in cancel worker
(#42520)
ad91767bdb2 is described below
commit ad91767bdb245add3b21de428f76880aec22bcc7
Author: Gabriel <[email protected]>
AuthorDate: Tue Oct 29 10:22:08 2024 +0800
[refactor](cancel) Reduce lock scope in cancel worker (#42520)
In cancel worker, lock should not be hold too much time.
---
be/src/runtime/fragment_mgr.cpp | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/be/src/runtime/fragment_mgr.cpp b/be/src/runtime/fragment_mgr.cpp
index a12d24c7608..dae4c60f26b 100644
--- a/be/src/runtime/fragment_mgr.cpp
+++ b/be/src/runtime/fragment_mgr.cpp
@@ -899,11 +899,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)) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]