This is an automated email from the ASF dual-hosted git repository.

yiguolei 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 e47d1fccf5 [bugfix](be core) fragment executor's destruct method 
should be called before query context (#22362)
e47d1fccf5 is described below

commit e47d1fccf59c8eff57eb7fb823287f89bd5b0adf
Author: yiguolei <676222...@qq.com>
AuthorDate: Sat Jul 29 22:41:46 2023 +0800

    [bugfix](be core) fragment executor's destruct method should be called 
before query context (#22362)
    
    fragment executor's destruct method will call close, it depends on query 
context's object pool, because many object is put in query context's object 
pool such as runtime filter.
    It should be deleted before query context. Or there will be heap use after 
free error.
    It is fixed in #17675, but Do not know why not in master. So 1.2-lts does 
not have this problem.
    ---------
    
    Co-authored-by: yiguolei <yiguo...@gmail.com>
---
 be/src/runtime/fragment_mgr.cpp | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/be/src/runtime/fragment_mgr.cpp b/be/src/runtime/fragment_mgr.cpp
index bce4db795d..9b184f6c33 100644
--- a/be/src/runtime/fragment_mgr.cpp
+++ b/be/src/runtime/fragment_mgr.cpp
@@ -183,6 +183,11 @@ private:
     int _backend_num;
     TNetworkAddress _coord_addr;
 
+    // This context is shared by all fragments of this host in a query.
+    // _query_ctx should be the last one to be destructed, because _executor's
+    // destruct method will call close and it will depend on query context,
+    // for example runtime profile.
+    std::shared_ptr<QueryContext> _query_ctx;
     PlanFragmentExecutor _executor;
     vectorized::VecDateTimeValue _start_time;
 
@@ -196,9 +201,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<QueryContext> _query_ctx;
-
     std::shared_ptr<RuntimeFilterMergeControllerEntity> 
_merge_controller_handler;
 
     // If set the true, this plan fragment will be executed only after FE send 
execution start rpc.
@@ -213,12 +215,12 @@ FragmentExecState::FragmentExecState(const TUniqueId& 
query_id,
         : _query_id(query_id),
           _fragment_instance_id(fragment_instance_id),
           _backend_num(backend_num),
+          _query_ctx(std::move(query_ctx)),
           _executor(exec_env, 
std::bind<void>(std::mem_fn(&FragmentExecState::coordinator_callback),
                                               this, std::placeholders::_1, 
std::placeholders::_2,
                                               std::placeholders::_3, 
std::placeholders::_4)),
           _set_rsc_info(false),
           _timeout_second(-1),
-          _query_ctx(std::move(query_ctx)),
           _report_status_cb_impl(report_status_cb_impl) {
     _start_time = vectorized::VecDateTimeValue::local_time();
     _coord_addr = _query_ctx->coord_addr;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to