From 235ae9ded49fabe44d8ef66005a106ee319710d8 Mon Sep 17 00:00:00 2001 From: HHoflittlefish777 <77738092+HHoflittlefish777@users.noreply.github.com> Date: Wed, 25 Oct 2023 14:03:47 +0800 Subject: [PATCH] [improvement](fragment) optimize to get query context logic (#25621) --- be/src/runtime/fragment_mgr.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/be/src/runtime/fragment_mgr.cpp b/be/src/runtime/fragment_mgr.cpp index 2e413c6a44..1fb68049e6 100644 --- a/be/src/runtime/fragment_mgr.cpp +++ b/be/src/runtime/fragment_mgr.cpp @@ -584,6 +584,17 @@ Status FragmentMgr::_get_query_ctx(const Params& params, TUniqueId query_id, boo } query_ctx = search->second; } else { + { + // Find _query_ctx_map, in case some other request has already + // create the query fragments context. + std::lock_guard lock(_lock); + auto search = _query_ctx_map.find(query_id); + if (search != _query_ctx_map.end()) { + query_ctx = search->second; + return Status::OK(); + } + } + // This may be a first fragment request of the query. // Create the query fragments context. query_ctx = QueryContext::create_shared(query_id, params.fragment_num_on_host, _exec_env,