From 466f91c13beb801b3c40c494afe7c80a48a3a8fe Mon Sep 17 00:00:00 2001 From: zhengyu Date: Mon, 6 Nov 2023 22:50:32 +0800 Subject: [PATCH] [fix](load) fix merged row number miscounting because of race condition (#26470) row numbers miscounting because of race condition, will cause load to fail sometimes with warning 'the rows number written doesn't match'. Signed-off-by: freemandealer --- be/src/olap/delta_writer.h | 2 +- be/src/olap/memtable.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/be/src/olap/delta_writer.h b/be/src/olap/delta_writer.h index 303f17f14f8f36..fd41473292e5f6 100644 --- a/be/src/olap/delta_writer.h +++ b/be/src/olap/delta_writer.h @@ -133,7 +133,7 @@ class DeltaWriter { std::shared_mutex _slave_node_lock; // total rows num written by DeltaWriter - int64_t _total_received_rows = 0; + std::atomic _total_received_rows = 0; RuntimeProfile* _profile = nullptr; RuntimeProfile::Counter* _close_wait_timer = nullptr; diff --git a/be/src/olap/memtable.h b/be/src/olap/memtable.h index b98e7411e3b1cc..cade509aac5ce1 100644 --- a/be/src/olap/memtable.h +++ b/be/src/olap/memtable.h @@ -155,14 +155,14 @@ class MemTableStat { return *this; } - int64_t raw_rows = 0; - int64_t merged_rows = 0; + std::atomic raw_rows = 0; + std::atomic merged_rows = 0; int64_t sort_ns = 0; int64_t agg_ns = 0; int64_t put_into_output_ns = 0; int64_t duration_ns = 0; - int64_t sort_times = 0; - int64_t agg_times = 0; + std::atomic sort_times = 0; + std::atomic agg_times = 0; }; class MemTable {