diff --git a/be/src/olap/delta_writer.cpp b/be/src/olap/delta_writer.cpp index 1c2f24ae6d94d3..f49a68985d8606 100644 --- a/be/src/olap/delta_writer.cpp +++ b/be/src/olap/delta_writer.cpp @@ -126,8 +126,7 @@ Status BaseDeltaWriter::write(const vectorized::Block* block, const std::vector< if (!_is_init && !_is_cancelled) { RETURN_IF_ERROR(init()); } - while (_memtable_writer->get_flush_token_stats().flush_running_count >= - config::memtable_flush_running_count_limit) { + while (_memtable_writer->flush_running_count() >= config::memtable_flush_running_count_limit) { std::this_thread::sleep_for(std::chrono::milliseconds(10)); } return _memtable_writer->write(block, row_idxs, is_append); diff --git a/be/src/olap/delta_writer_v2.cpp b/be/src/olap/delta_writer_v2.cpp index cfe059f1890c89..bca1213b047480 100644 --- a/be/src/olap/delta_writer_v2.cpp +++ b/be/src/olap/delta_writer_v2.cpp @@ -37,7 +37,6 @@ #include "gutil/strings/numbers.h" #include "io/fs/file_writer.h" // IWYU pragma: keep #include "olap/data_dir.h" -#include "olap/memtable_flush_executor.h" #include "olap/olap_define.h" #include "olap/rowset/beta_rowset.h" #include "olap/rowset/beta_rowset_writer_v2.h" @@ -153,8 +152,7 @@ Status DeltaWriterV2::write(const vectorized::Block* block, const std::vectorget_flush_token_stats().flush_running_count >= - config::memtable_flush_running_count_limit) { + while (_memtable_writer->flush_running_count() >= config::memtable_flush_running_count_limit) { std::this_thread::sleep_for(std::chrono::milliseconds(10)); } SCOPED_RAW_TIMER(&_write_memtable_time); diff --git a/be/src/olap/memtable_writer.cpp b/be/src/olap/memtable_writer.cpp index 1faed6c328b167..c967cdbd483968 100644 --- a/be/src/olap/memtable_writer.cpp +++ b/be/src/olap/memtable_writer.cpp @@ -345,6 +345,10 @@ const FlushStatistic& MemTableWriter::get_flush_token_stats() { return _flush_token->get_stats(); } +uint64_t MemTableWriter::flush_running_count() const { + return _flush_token == nullptr ? 0 : _flush_token->get_stats().flush_running_count.load(); +} + int64_t MemTableWriter::mem_consumption(MemType mem) { if (!_is_init) { // This method may be called before this writer is initialized. diff --git a/be/src/olap/memtable_writer.h b/be/src/olap/memtable_writer.h index c5459c09065cda..a2687d9402cdca 100644 --- a/be/src/olap/memtable_writer.h +++ b/be/src/olap/memtable_writer.h @@ -109,6 +109,8 @@ class MemTableWriter { const FlushStatistic& get_flush_token_stats(); + uint64_t flush_running_count() const; + private: // push a full memtable to flush executor Status _flush_memtable_async();