From eff076b35526d079d85e4fc24702f81aebbbe83c Mon Sep 17 00:00:00 2001 From: Xinyi Zou Date: Sat, 16 Oct 2021 21:57:09 +0800 Subject: [PATCH] [BUG] Fix printing ReservationTrackerCounters cause BE crash when mem_limit is reached (#6849) When the memory usage of BE reaches mem_limit, printing ReservationTrackerCounters through MemTracker may cause BE crash in high concurrency. ReservationTrackerCounters is not actually used in the current Doris, and the memory tracker in Doris will be redesigned in the future. --- be/src/runtime/mem_tracker.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/be/src/runtime/mem_tracker.cpp b/be/src/runtime/mem_tracker.cpp index ea0a16984a..ab8a5aaaec 100644 --- a/be/src/runtime/mem_tracker.cpp +++ b/be/src/runtime/mem_tracker.cpp @@ -369,16 +369,19 @@ std::string MemTracker::LogUsage(int max_recursive_depth, const string& prefix, if (CheckLimitExceeded(MemLimit::HARD)) ss << " memory limit exceeded."; if (limit_ > 0) ss << " Limit=" << PrettyPrinter::print(limit_, TUnit::BYTES); - ReservationTrackerCounters* reservation_counters = reservation_counters_.load(); - if (reservation_counters != nullptr) { - int64_t reservation = reservation_counters->peak_reservation->current_value(); - ss << " Reservation=" << PrettyPrinter::print(reservation, TUnit::BYTES); - if (reservation_counters->reservation_limit != nullptr) { - int64_t limit = reservation_counters->reservation_limit->value(); - ss << " ReservationLimit=" << PrettyPrinter::print(limit, TUnit::BYTES); - } - ss << " OtherMemory=" << PrettyPrinter::print(curr_consumption - reservation, TUnit::BYTES); - } + // TODO(zxy): ReservationTrackerCounters is not actually used in the current Doris. + // Printing here ReservationTrackerCounters may cause BE crash when high concurrency. + // The memory tracker in Doris will be redesigned in the future. + // ReservationTrackerCounters* reservation_counters = reservation_counters_.load(); + // if (reservation_counters != nullptr) { + // int64_t reservation = reservation_counters->peak_reservation->current_value(); + // ss << " Reservation=" << PrettyPrinter::print(reservation, TUnit::BYTES); + // if (reservation_counters->reservation_limit != nullptr) { + // int64_t limit = reservation_counters->reservation_limit->value(); + // ss << " ReservationLimit=" << PrettyPrinter::print(limit, TUnit::BYTES); + // } + // ss << " OtherMemory=" << PrettyPrinter::print(curr_consumption - reservation, TUnit::BYTES); + // } ss << " Total=" << PrettyPrinter::print(curr_consumption, TUnit::BYTES); // Peak consumption is not accurate if the metric is lazily updated (i.e. // this is a non-root tracker that exists only for reporting purposes).