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

wangbo 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 277329c035e [fix](auditlog) fix without lock in QueryStatisticsRecvr 
find #26440
277329c035e is described below

commit 277329c035e00d95115194d769de1828751b1582
Author: Mryange <59914473+mrya...@users.noreply.github.com>
AuthorDate: Tue Nov 7 13:53:22 2023 +0800

    [fix](auditlog) fix without lock in QueryStatisticsRecvr find #26440
---
 be/src/runtime/query_statistics.cpp | 16 +++++++++++++---
 be/src/runtime/query_statistics.h   |  2 ++
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/be/src/runtime/query_statistics.cpp 
b/be/src/runtime/query_statistics.cpp
index 22c18faa1e6..dfe63f57626 100644
--- a/be/src/runtime/query_statistics.cpp
+++ b/be/src/runtime/query_statistics.cpp
@@ -88,9 +88,10 @@ void QueryStatistics::merge(QueryStatisticsRecvr* recvr) {
 }
 
 void QueryStatistics::merge(QueryStatisticsRecvr* recvr, int sender_id) {
-    auto it = recvr->_query_statistics.find(sender_id);
-    if (it != recvr->_query_statistics.end()) {
-        merge(*it->second);
+    DCHECK(recvr != nullptr);
+    auto QueryStatisticsptr = recvr->find(sender_id);
+    if (QueryStatisticsptr) {
+        merge(*QueryStatisticsptr);
     }
 }
 
@@ -120,4 +121,13 @@ void QueryStatisticsRecvr::insert(QueryStatisticsPtr 
statistics, int sender_id)
     _query_statistics[sender_id] = statistics;
 }
 
+QueryStatisticsPtr QueryStatisticsRecvr::find(int sender_id) {
+    std::lock_guard<SpinLock> l(_lock);
+    auto it = _query_statistics.find(sender_id);
+    if (it != _query_statistics.end()) {
+        return it->second;
+    }
+    return nullptr;
+}
+
 } // namespace doris
diff --git a/be/src/runtime/query_statistics.h 
b/be/src/runtime/query_statistics.h
index 42c1457472f..d32b7a60e2a 100644
--- a/be/src/runtime/query_statistics.h
+++ b/be/src/runtime/query_statistics.h
@@ -140,6 +140,8 @@ public:
     // using local_exchange for transmission, only need to hold a shared 
pointer.
     void insert(QueryStatisticsPtr statistics, int sender_id);
 
+    QueryStatisticsPtr find(int sender_id);
+
 private:
     friend class QueryStatistics;
 


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

Reply via email to