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

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


The following commit(s) were added to refs/heads/branch-2.1 by this push:
     new 86ea0f2b813 [fix](be) Fix be aws-sdk-cpp memory leak (#52185) (#52298)
86ea0f2b813 is described below

commit 86ea0f2b8133250ec7c9ba75c14f89a6b7f80720
Author: Lei Zhang <[email protected]>
AuthorDate: Sat Jun 28 10:10:32 2025 +0800

    [fix](be) Fix be aws-sdk-cpp memory leak (#52185) (#52298)
    
    * https://github.com/aws/aws-sdk-cpp/pull/2314
    * In the aws-sdk-cpp code, there is a suggestion: "Please call
    ShutdownAPI from the same thread from which InitAPI() has been called"
    otherwise it will cause memory leak.
    
    ```
    =================================================================
    ==3271527==ERROR: LeakSanitizer: detected memory leaks
    
    Direct leak of 216 byte(s) in 1 object(s) allocated from:
        #0 0x555f9ecf55ee in malloc 
(/mnt/ssd01/pipline/OpenSourceDoris/clusterEnv/P0/Cluster0/be/lib/doris_be+0x370815ee)
 (BuildId: 22b637395dd039b0)
        #1 0x555fd8e19bd7 in CRYPTO_zalloc 
(/mnt/ssd01/pipline/OpenSourceDoris/clusterEnv/P0/Cluster0/be/lib/doris_be+0x711a5bd7)
 (BuildId: 22b637395dd039b0)
        #2 0x555fda7c9d14 in aws_mqtt_library_init 
(/mnt/ssd01/pipline/OpenSourceDoris/clusterEnv/P0/Cluster0/be/lib/doris_be+0x72b55d14)
 (BuildId: 22b637395dd039b0)
        #3 0x555fda74ed1f in Aws::Crt::ApiHandle::ApiHandle(aws_allocator*) 
(/mnt/ssd01/pipline/OpenSourceDoris/clusterEnv/P0/Cluster0/be/lib/doris_be+0x72adad1f)
 (BuildId: 22b637395dd039b0)
        #4 0x555fa365f0c9 in doris::S3ClientFactory::instance() 
/root/doris/be/src/util/s3_util.cpp:188:28
        #5 0x555f9f13b87b in doris::io::ObjClientHolder::init() 
/root/doris/be/src/io/fs/s3_file_system.cpp:78:15
        #6 0x555f9f140eee in doris::io::S3FileSystem::init() 
/root/doris/be/src/io/fs/s3_file_system.cpp:182:21
        ......
    ```
    
    ### What problem does this PR solve?
    
    Issue Number: close #xxx
    
    Related PR: #xxx
    
    Problem Summary:
    
    ### Release note
    
    None
    
    ### Check List (For Author)
    
    - Test <!-- At least one of them must be included. -->
        - [ ] Regression test
        - [ ] Unit Test
        - [ ] Manual test (add detailed scripts or steps below)
        - [ ] No need to test or manual test. Explain why:
    - [ ] This is a refactor/code format and no logic has been changed.
            - [ ] Previous test can cover this change.
            - [ ] No code files have been changed.
            - [ ] Other reason <!-- Add your reason?  -->
    
    - Behavior changed:
        - [ ] No.
        - [ ] Yes. <!-- Explain the behavior change -->
    
    - Does this need documentation?
        - [ ] No.
    - [ ] Yes. <!-- Add document PR link here. eg:
    https://github.com/apache/doris-website/pull/1214 -->
    
    ### Check List (For Reviewer who merge this PR)
    
    - [ ] Confirm the release note
    - [ ] Confirm test cases
    - [ ] Confirm document
    - [ ] Add branch pick label <!-- Add branch pick label that this PR
    should merge into -->
---
 be/src/runtime/exec_env_init.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/be/src/runtime/exec_env_init.cpp b/be/src/runtime/exec_env_init.cpp
index 22a31c0cbe7..bcb01a6336f 100644
--- a/be/src/runtime/exec_env_init.cpp
+++ b/be/src/runtime/exec_env_init.cpp
@@ -93,6 +93,7 @@
 #include "util/metrics.h"
 #include "util/parse_util.h"
 #include "util/pretty_printer.h"
+#include "util/s3_util.h"
 #include "util/threadpool.h"
 #include "util/thrift_rpc_helper.h"
 #include "util/timezone_utils.h"
@@ -308,6 +309,8 @@ Status ExecEnv::_init(const std::vector<StorePath>& 
store_paths,
 
     _s_ready = true;
 
+    // Make aws-sdk-cpp InitAPI and ShutdownAPI called in the same thread
+    S3ClientFactory::instance();
     return Status::OK();
 }
 


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

Reply via email to