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 aa50f7fb638 [metrics](storage) Add metrics (just bvar) for memtable 
flushes triggered by different reasons. (#57229)
aa50f7fb638 is described below

commit aa50f7fb638cefdf90e60ec769ea12a864530228
Author: Refrain <[email protected]>
AuthorDate: Tue Oct 28 01:51:00 2025 +0800

    [metrics](storage) Add metrics (just bvar) for memtable flushes triggered 
by different reasons. (#57229)
---
 be/src/olap/memtable.cpp                |  8 +++++++-
 be/src/olap/memtable_memory_limiter.cpp | 11 ++++++++++-
 be/src/olap/memtable_writer.cpp         |  3 +++
 3 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/be/src/olap/memtable.cpp b/be/src/olap/memtable.cpp
index 18e85503c33..8a6cb67f714 100644
--- a/be/src/olap/memtable.cpp
+++ b/be/src/olap/memtable.cpp
@@ -45,6 +45,7 @@ namespace doris {
 #include "common/compile_check_begin.h"
 
 bvar::Adder<int64_t> g_memtable_cnt("memtable_cnt");
+bvar::Adder<uint64_t> g_flush_cuz_memtable_full("flush_cuz_memtable_full");
 
 using namespace ErrorCode;
 
@@ -665,7 +666,12 @@ bool MemTable::need_flush() const {
         max_size = max_size * update_columns_size / 
_tablet_schema->num_columns();
         max_size = max_size > min_buffer_size ? max_size : min_buffer_size;
     }
-    return memory_usage() >= max_size;
+
+    if (memory_usage() >= max_size) {
+        g_flush_cuz_memtable_full << 1;
+        return true;
+    }
+    return false;
 }
 
 int64_t MemTable::_adaptive_write_buffer_size() const {
diff --git a/be/src/olap/memtable_memory_limiter.cpp 
b/be/src/olap/memtable_memory_limiter.cpp
index c8caf5194d6..b92a0addc9d 100644
--- a/be/src/olap/memtable_memory_limiter.cpp
+++ b/be/src/olap/memtable_memory_limiter.cpp
@@ -40,6 +40,8 @@ bvar::Status<int64_t> 
g_memtable_flush_memory("mm_limiter_mem_flush", 0);
 bvar::Status<int64_t> g_memtable_load_memory("mm_limiter_mem_load", 0);
 bvar::Status<int64_t> g_load_hard_mem_limit("mm_limiter_limit_hard", 0);
 bvar::Status<int64_t> g_load_soft_mem_limit("mm_limiter_limit_soft", 0);
+bvar::Adder<uint64_t> 
g_flush_cuz_load_mem_exceed_hard_limit("flush_cuz_hard_limit");
+bvar::Adder<uint64_t> 
g_flush_cuz_sys_mem_exceed_soft_limit("flush_cuz_soft_limit");
 bvar::Adder<int> 
g_memtable_memory_limit_flush_memtable_count("mm_limiter_flush_memtable_count");
 bvar::LatencyRecorder 
g_memtable_memory_limit_flush_size_bytes("mm_limiter_flush_size_bytes");
 
@@ -115,7 +117,7 @@ int64_t MemTableMemoryLimiter::_need_flush() {
     int64_t limit1 = _mem_tracker->consumption() - _load_soft_mem_limit;
     int64_t limit2 = _sys_avail_mem_less_than_warning_water_mark();
     int64_t limit3 = _process_used_mem_more_than_soft_mem_limit();
-    int64_t need_flush = std::max(limit1, std::max(limit2, limit3));
+    int64_t need_flush = std::max({limit1, limit2, limit3});
     return need_flush - _queue_mem_usage - _flush_mem_usage;
 }
 
@@ -166,6 +168,13 @@ void 
MemTableMemoryLimiter::handle_memtable_flush(std::function<bool()> cancel_c
                                        ->process_memory_detail_str();
                 LOG_LONG_STRING(INFO, log_str);
             }
+            if (limit == Limit::HARD) {
+                g_flush_cuz_load_mem_exceed_hard_limit << 1;
+            } else if (limit == Limit::SOFT) {
+                g_flush_cuz_sys_mem_exceed_soft_limit << 1;
+            } else {
+                // will not reach here
+            }
             _flush_active_memtables(need_flush);
         }
     } while (_hard_limit_reached() && !_load_usage_low());
diff --git a/be/src/olap/memtable_writer.cpp b/be/src/olap/memtable_writer.cpp
index 95ad9c192aa..12f0c070ade 100644
--- a/be/src/olap/memtable_writer.cpp
+++ b/be/src/olap/memtable_writer.cpp
@@ -46,6 +46,8 @@
 #include "vec/core/block.h"
 
 namespace doris {
+bvar::Adder<uint64_t> g_flush_cuz_rowscnt_oveflow("flush_cuz_rowscnt_oveflow");
+
 using namespace ErrorCode;
 
 MemTableWriter::MemTableWriter(const WriteRequest& req) : _req(req) {}
@@ -108,6 +110,7 @@ Status MemTableWriter::write(const vectorized::Block* block,
     DBUG_EXECUTE_IF("MemTableWriter.too_many_raws",
                     { raw_rows = std::numeric_limits<int32_t>::max(); });
     if (raw_rows + row_idxs.size() > std::numeric_limits<int32_t>::max()) {
+        g_flush_cuz_rowscnt_oveflow << 1;
         RETURN_IF_ERROR(_flush_memtable());
     }
 


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

Reply via email to