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

liaoxin 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 e4a1d3ddd2a [fix](cloud) fix double free when get_error_log_file_path 
(#41320)
e4a1d3ddd2a is described below

commit e4a1d3ddd2a554b30417af15df7409e43a1ee417
Author: Xin Liao <liaoxin...@126.com>
AuthorDate: Thu Sep 26 14:20:13 2024 +0800

    [fix](cloud) fix double free when get_error_log_file_path (#41320)
    
    After #40924, `get_error_log_file_path` might be accessed concurrently,
    leading to error_log_file being closed multiple times. Therefore, a lock
    was added to solve this issue.
---
 be/src/runtime/runtime_state.cpp | 1 +
 be/src/runtime/runtime_state.h   | 1 +
 2 files changed, 2 insertions(+)

diff --git a/be/src/runtime/runtime_state.cpp b/be/src/runtime/runtime_state.cpp
index 4930048ed80..d4e3cba36cd 100644
--- a/be/src/runtime/runtime_state.cpp
+++ b/be/src/runtime/runtime_state.cpp
@@ -434,6 +434,7 @@ Status 
RuntimeState::append_error_msg_to_file(std::function<std::string()> line,
 }
 
 std::string RuntimeState::get_error_log_file_path() {
+    std::lock_guard<std::mutex> l(_s3_error_log_file_lock);
     if (_s3_error_fs && _error_log_file && _error_log_file->is_open()) {
         // close error log file
         _error_log_file->close();
diff --git a/be/src/runtime/runtime_state.h b/be/src/runtime/runtime_state.h
index 90cf1bc34bd..e7f2c18b094 100644
--- a/be/src/runtime/runtime_state.h
+++ b/be/src/runtime/runtime_state.h
@@ -735,6 +735,7 @@ private:
     std::shared_ptr<io::S3FileSystem> _s3_error_fs;
     // error file path on s3, 
${bucket}/${prefix}/error_log/${label}_${fragment_instance_id}
     std::string _s3_error_log_file_path;
+    std::mutex _s3_error_log_file_lock;
 };
 
 #define RETURN_IF_CANCELLED(state)               \


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

Reply via email to