This is an automated email from the ASF dual-hosted git repository. yiguolei pushed a commit to branch branch-1.2-lts in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-1.2-lts by this push: new 732d0f0711 [fix](fragmen mgr) fix possible coredump of FragmentExecState destruction (#17675) 732d0f0711 is described below commit 732d0f071101f884b9a4da19d628355d15e45d8b Author: TengJianPing <18241664+jackte...@users.noreply.github.com> AuthorDate: Fri Mar 10 21:23:18 2023 +0800 [fix](fragmen mgr) fix possible coredump of FragmentExecState destruction (#17675) When FragmentExecState is destroied, PlanFragmentExecutor destructor will still access some objects created by _fragments_ctx->obj_pool, but FragmentExecState::_fragments_ctx maybe destructed before FragmentExecState::_executor, so as for all objects created by _fragments_ctx->obj_pool, so it wil cause coredump. --- be/src/runtime/fragment_mgr.cpp | 17 +++++++++++------ be/src/runtime/query_fragments_ctx.h | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/be/src/runtime/fragment_mgr.cpp b/be/src/runtime/fragment_mgr.cpp index a332583739..37b2f86a5a 100644 --- a/be/src/runtime/fragment_mgr.cpp +++ b/be/src/runtime/fragment_mgr.cpp @@ -147,6 +147,14 @@ public: private: void coordinator_callback(const Status& status, RuntimeProfile* profile, bool done); + // This context is shared by all fragments of this host in a query + // + // NOTE: _fragments_ctx should be declared at the beginning of members so that + // it's destructed last. + // Because Objects create in _fragments_ctx.obj_pool maybe used during + // destruction, if _fragments_ctx is destructed too early, it will coredump. + std::shared_ptr<QueryFragmentsCtx> _fragments_ctx; + // Id of this query TUniqueId _query_id; // Id of this instance @@ -169,9 +177,6 @@ private: int _timeout_second; std::atomic<bool> _cancelled {false}; - // This context is shared by all fragments of this host in a query - std::shared_ptr<QueryFragmentsCtx> _fragments_ctx; - std::shared_ptr<RuntimeFilterMergeControllerEntity> _merge_controller_handler; // The pipe for data transfering, such as insert. std::shared_ptr<StreamLoadPipe> _pipe; @@ -184,7 +189,8 @@ FragmentExecState::FragmentExecState(const TUniqueId& query_id, const TUniqueId& fragment_instance_id, int backend_num, ExecEnv* exec_env, std::shared_ptr<QueryFragmentsCtx> fragments_ctx) - : _query_id(query_id), + : _fragments_ctx(std::move(fragments_ctx)), + _query_id(query_id), _fragment_instance_id(fragment_instance_id), _backend_num(backend_num), _exec_env(exec_env), @@ -192,8 +198,7 @@ FragmentExecState::FragmentExecState(const TUniqueId& query_id, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)), _set_rsc_info(false), - _timeout_second(-1), - _fragments_ctx(std::move(fragments_ctx)) { + _timeout_second(-1) { _start_time = DateTimeValue::local_time(); _coord_addr = _fragments_ctx->coord_addr; } diff --git a/be/src/runtime/query_fragments_ctx.h b/be/src/runtime/query_fragments_ctx.h index 543b9868b5..c6a47ca9a7 100644 --- a/be/src/runtime/query_fragments_ctx.h +++ b/be/src/runtime/query_fragments_ctx.h @@ -108,6 +108,7 @@ public: } public: + ObjectPool obj_pool; TUniqueId query_id; DescriptorTbl* desc_tbl; bool set_rsc_info = false; @@ -125,7 +126,6 @@ public: /// will clean up QueryFragmentsCtx. std::atomic<int> fragment_num; int timeout_second; - ObjectPool obj_pool; // MemTracker that is shared by all fragment instances running on this host. std::shared_ptr<MemTrackerLimiter> query_mem_tracker; --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org