You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by yi...@apache.org on 2023/06/29 12:27:59 UTC

[doris] branch branch-1.2-lts updated: [bugfix](memleak) expr context has memory leak during runtime filter (#21347)

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 2141fc0f39 [bugfix](memleak) expr context has memory leak during runtime filter (#21347)
2141fc0f39 is described below

commit 2141fc0f3993a7bab29b3ba2e516a667cb3e7e12
Author: yiguolei <67...@qq.com>
AuthorDate: Thu Jun 29 20:27:50 2023 +0800

    [bugfix](memleak) expr context has memory leak during runtime filter (#21347)
    
    
    
    ---------
    
    Co-authored-by: yiguolei <yi...@gmail.com>
---
 be/src/vec/exprs/vexpr.cpp | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/be/src/vec/exprs/vexpr.cpp b/be/src/vec/exprs/vexpr.cpp
index f584816bf3..bdda643b78 100644
--- a/be/src/vec/exprs/vexpr.cpp
+++ b/be/src/vec/exprs/vexpr.cpp
@@ -399,10 +399,17 @@ Status VExpr::init_function_context(VExprContext* context,
 
 void VExpr::close_function_context(VExprContext* context, FunctionContext::FunctionStateScope scope,
                                    const FunctionBasePtr& function) const {
-    if (_fn_context_index != -1 && !context->_stale) {
+    if (_fn_context_index != -1) {
         FunctionContext* fn_ctx = context->fn_context(_fn_context_index);
         function->close(fn_ctx, FunctionContext::THREAD_LOCAL);
-        if (scope == FunctionContext::FRAGMENT_LOCAL) {
+        // In doris 1.2-lts, the function state is managed by raw ptr, in master, it is already using shared ptr
+        // During runtime filter, scan node will clone function context and mark the expr context as stale.
+        // During clone function context, the clone function does not clone thread local state, so thread local state
+        // is not managed by the aim expr context.
+        // So we has to close the stale function context's thread local state here.
+        // Should not close stale's fragment local state, because the fragment local state is cloned during function
+        // context's clone method.
+        if (scope == FunctionContext::FRAGMENT_LOCAL && !context->_stale) {
             function->close(fn_ctx, FunctionContext::FRAGMENT_LOCAL);
         }
     }


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