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

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

commit ec9c39bb3f87b42b2831b3a1f8d2fb12cd156b44
Author: Kaijie Chen <c...@apache.org>
AuthorDate: Tue Sep 5 09:11:55 2023 +0800

    [fix](load) add lock for serialize profile (#23856)
---
 be/src/runtime/load_channel.cpp | 3 ++-
 be/src/runtime/load_channel.h   | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/be/src/runtime/load_channel.cpp b/be/src/runtime/load_channel.cpp
index 29ebb63725..7b72e20cc8 100644
--- a/be/src/runtime/load_channel.cpp
+++ b/be/src/runtime/load_channel.cpp
@@ -165,10 +165,11 @@ void 
LoadChannel::_report_profile(PTabletWriterAddBlockResult* response) {
     }
 
     TRuntimeProfileTree tprofile;
-    _profile->to_thrift(&tprofile);
     ThriftSerializer ser(false, 4096);
     uint8_t* buf = nullptr;
     uint32_t len = 0;
+    std::lock_guard<SpinLock> l(_profile_serialize_lock);
+    _profile->to_thrift(&tprofile);
     auto st = ser.serialize(&tprofile, &len, &buf);
     if (st.ok()) {
         response->set_load_channel_profile(std::string((const char*)buf, len));
diff --git a/be/src/runtime/load_channel.h b/be/src/runtime/load_channel.h
index 3b5b4b2d58..4f0c0cc758 100644
--- a/be/src/runtime/load_channel.h
+++ b/be/src/runtime/load_channel.h
@@ -154,6 +154,7 @@ private:
     // Tracks the total memory consumed by current load job on this BE
     std::unique_ptr<MemTracker> _mem_tracker;
 
+    SpinLock _profile_serialize_lock;
     std::unique_ptr<RuntimeProfile> _profile;
     RuntimeProfile* _self_profile;
     RuntimeProfile::Counter* _add_batch_number_counter = nullptr;


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

Reply via email to