diff --git a/be/src/runtime/load_channel_mgr.h b/be/src/runtime/load_channel_mgr.h index b9182d8a00..6b30503f0c 100644 --- a/be/src/runtime/load_channel_mgr.h +++ b/be/src/runtime/load_channel_mgr.h @@ -170,6 +170,8 @@ Status LoadChannelMgr::_handle_mem_exceed_limit(TabletWriterAddResult* response) } // Pick load channel to reduce memory. std::shared_ptr channel; + // Indicate whether current thread is reducing mem on hard limit. + bool reducing_mem_on_hard_limit = false; { std::unique_lock l(_lock); while (_should_wait_flush) { @@ -216,12 +218,14 @@ Status LoadChannelMgr::_handle_mem_exceed_limit(TabletWriterAddResult* response) << " has exceeded"; if (_mem_tracker->consumption() > _load_hard_mem_limit) { _should_wait_flush = true; + reducing_mem_on_hard_limit = true; oss << " hard limit: " << PrettyPrinter::print(_load_hard_mem_limit, TUnit::BYTES); } else { oss << " soft limit: " << PrettyPrinter::print(_load_soft_mem_limit, TUnit::BYTES); } } else { _should_wait_flush = true; + reducing_mem_on_hard_limit = true; oss << "reducing memory of " << *channel << " because process memory used " << PerfCounters::get_vm_rss_str() << " has exceeded limit " << PrettyPrinter::print(process_mem_limit, TUnit::BYTES) @@ -238,7 +242,9 @@ Status LoadChannelMgr::_handle_mem_exceed_limit(TabletWriterAddResult* response) { std::lock_guard l(_lock); - if (_should_wait_flush) { + // If a thread have finished the memtable flush for soft limit, and now + // the hard limit is already reached, it should not update these variables. + if (reducing_mem_on_hard_limit && _should_wait_flush) { _should_wait_flush = false; _wait_flush_cond.notify_all(); }