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

yiguolei pushed a commit to branch branch-1.1-lts
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-1.1-lts by this push:
     new a05abfa43a [Fix](load) Fix memory leak for stream load 2pc #16430 
(#17085)
a05abfa43a is described below

commit a05abfa43acb2834dd28dcac5f66754cd00f561e
Author: weizuo93 <[email protected]>
AuthorDate: Mon Feb 27 08:50:41 2023 +0800

    [Fix](load) Fix memory leak for stream load 2pc #16430 (#17085)
    
    StreamLoadContext is not deleted correctly.
    
    Co-authored-by: weizuo <[email protected]>
---
 be/src/http/action/stream_load_2pc.cpp | 14 ++++++++++++++
 be/src/http/action/stream_load_2pc.h   |  1 +
 2 files changed, 15 insertions(+)

diff --git a/be/src/http/action/stream_load_2pc.cpp 
b/be/src/http/action/stream_load_2pc.cpp
index 511bce9015..5307ab1778 100644
--- a/be/src/http/action/stream_load_2pc.cpp
+++ b/be/src/http/action/stream_load_2pc.cpp
@@ -99,4 +99,18 @@ std::string StreamLoad2PCAction::get_success_info(const 
std::string txn_id, cons
     return s.GetString();
 }
 
+void StreamLoad2PCAction::free_handler_ctx(void* param) {
+    StreamLoadContext* ctx = (StreamLoadContext*)param;
+    if (ctx == nullptr) {
+        return;
+    }
+    // sender is gone, make receiver know it
+    if (ctx->body_sink != nullptr) {
+        ctx->body_sink->cancel("sender is gone");
+    }
+    if (ctx->unref()) {
+        delete ctx;
+    }
+}
+
 } // namespace doris
diff --git a/be/src/http/action/stream_load_2pc.h 
b/be/src/http/action/stream_load_2pc.h
index 7043b526ef..a221b5872c 100644
--- a/be/src/http/action/stream_load_2pc.h
+++ b/be/src/http/action/stream_load_2pc.h
@@ -32,6 +32,7 @@ public:
 
     void handle(HttpRequest* req) override;
     std::string get_success_info(const std::string txn_id, const std::string 
txn_operation);
+    void free_handler_ctx(void* param) override;
 
 private:
     ExecEnv* _exec_env;


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to