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,