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

dataroaring 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 23add67d14 [fix](load) fix core at memtable writer mem_consumption 
(#22914)
23add67d14 is described below

commit 23add67d143ee09f0fe000398355ec9ce1adc216
Author: Kaijie Chen <[email protected]>
AuthorDate: Sun Aug 13 10:10:28 2023 +0800

    [fix](load) fix core at memtable writer mem_consumption (#22914)
---
 be/src/olap/memtable_writer.cpp | 6 +++---
 be/src/olap/memtable_writer.h   | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/be/src/olap/memtable_writer.cpp b/be/src/olap/memtable_writer.cpp
index 8284001e47..b40d03a8ce 100644
--- a/be/src/olap/memtable_writer.cpp
+++ b/be/src/olap/memtable_writer.cpp
@@ -335,7 +335,7 @@ const FlushStatistic& 
MemTableWriter::get_flush_token_stats() {
 }
 
 int64_t MemTableWriter::mem_consumption(MemType mem) {
-    if (_flush_token == nullptr) {
+    if (!_is_init) {
         // This method may be called before this writer is initialized.
         // So _flush_token may be null.
         return 0;
@@ -344,12 +344,12 @@ int64_t MemTableWriter::mem_consumption(MemType mem) {
     {
         std::lock_guard<SpinLock> l(_mem_table_tracker_lock);
         if ((mem & MemType::WRITE) == MemType::WRITE) { // 3 & 2 = 2
-            for (auto mem_table_tracker : _mem_table_insert_trackers) {
+            for (const auto& mem_table_tracker : _mem_table_insert_trackers) {
                 mem_usage += mem_table_tracker->consumption();
             }
         }
         if ((mem & MemType::FLUSH) == MemType::FLUSH) { // 3 & 1 = 1
-            for (auto mem_table_tracker : _mem_table_flush_trackers) {
+            for (const auto& mem_table_tracker : _mem_table_flush_trackers) {
                 mem_usage += mem_table_tracker->consumption();
             }
         }
diff --git a/be/src/olap/memtable_writer.h b/be/src/olap/memtable_writer.h
index 92600e450e..ed09f61933 100644
--- a/be/src/olap/memtable_writer.h
+++ b/be/src/olap/memtable_writer.h
@@ -120,7 +120,7 @@ private:
 
     void _init_profile(RuntimeProfile* profile);
 
-    bool _is_init = false;
+    std::atomic<bool> _is_init = false;
     bool _is_cancelled = false;
     bool _is_closed = false;
     Status _cancel_status;


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

Reply via email to