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

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


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new 529260b8283 [improve](load) lock free flush_async and wait_flush in 
LoadChannel (#33389)
529260b8283 is described below

commit 529260b82832e237c85867c783f410fc82a24627
Author: Kaijie Chen <[email protected]>
AuthorDate: Wed Apr 10 10:17:28 2024 +0800

    [improve](load) lock free flush_async and wait_flush in LoadChannel (#33389)
---
 be/src/runtime/load_channel.h | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/be/src/runtime/load_channel.h b/be/src/runtime/load_channel.h
index 4f0c0cc758c..9e126d2e21c 100644
--- a/be/src/runtime/load_channel.h
+++ b/be/src/runtime/load_channel.h
@@ -100,19 +100,22 @@ public:
 
     bool is_high_priority() const { return _is_high_priority; }
 
-    void flush_memtable_async(int64_t index_id, int64_t tablet_id) {
+    std::shared_ptr<TabletsChannel> get_load_channel(int64_t index_id) {
         std::lock_guard<std::mutex> l(_lock);
-        auto it = _tablets_channels.find(index_id);
-        if (it != _tablets_channels.end()) {
-            it->second->flush_memtable_async(tablet_id);
+        return _tablets_channels[index_id];
+    }
+
+    void flush_memtable_async(int64_t index_id, int64_t tablet_id) {
+        auto channel = get_load_channel(index_id);
+        if (channel != nullptr) {
+            channel->flush_memtable_async(tablet_id);
         }
     }
 
     void wait_flush(int64_t index_id, int64_t tablet_id) {
-        std::lock_guard<std::mutex> l(_lock);
-        auto it = _tablets_channels.find(index_id);
-        if (it != _tablets_channels.end()) {
-            it->second->wait_flush(tablet_id);
+        auto channel = get_load_channel(index_id);
+        if (channel != nullptr) {
+            channel->wait_flush(tablet_id);
         }
     }
 


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

Reply via email to