Skip to content

Commit

Permalink
[fix](memory) fix mem tracker grace exit (#21136)
Browse files Browse the repository at this point in the history
  • Loading branch information
xinyiZzz authored and xiaokang committed Jul 3, 2023
1 parent 905bbc6 commit 290a860
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions be/src/runtime/exec_env_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,10 @@ void ExecEnv::_destroy() {
_join_node_thread_pool.reset(nullptr);
_serial_download_cache_thread_token.reset(nullptr);
_download_cache_thread_pool.reset(nullptr);
_orphan_mem_tracker.reset();
_experimental_mem_tracker.reset();
_page_no_cache_mem_tracker.reset();
_brpc_iobuf_block_memory_tracker.reset();

_is_init = false;
}
Expand Down
3 changes: 2 additions & 1 deletion be/src/runtime/memory/mem_tracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include <mutex>

#include "common/daemon.h"
#include "runtime/memory/mem_tracker_limiter.h"
#include "runtime/thread_context.h"

Expand Down Expand Up @@ -81,7 +82,7 @@ void MemTracker::bind_parent(MemTrackerLimiter* parent) {
}

MemTracker::~MemTracker() {
if (_parent_group_num != -1) {
if (_parent_group_num != -1 && !k_doris_exit) {
std::lock_guard<std::mutex> l(mem_tracker_pool[_parent_group_num].group_lock);
if (_tracker_group_it != mem_tracker_pool[_parent_group_num].trackers.end()) {
mem_tracker_pool[_parent_group_num].trackers.erase(_tracker_group_it);
Expand Down
3 changes: 2 additions & 1 deletion be/src/runtime/memory/mem_tracker_limiter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <queue>
#include <utility>

#include "common/daemon.h"
#include "runtime/exec_env.h"
#include "runtime/fragment_mgr.h"
#include "runtime/load_channel_mgr.h"
Expand Down Expand Up @@ -79,7 +80,7 @@ MemTrackerLimiter::~MemTrackerLimiter() {
// in real time. Merge its consumption into orphan when parent is process, to avoid repetition.
ExecEnv::GetInstance()->orphan_mem_tracker()->consume(_consumption->current_value());
_consumption->set(0);
{
if (!k_doris_exit) {
std::lock_guard<std::mutex> l(mem_tracker_limiter_pool[_group_num].group_lock);
if (_tracker_limiter_group_it != mem_tracker_limiter_pool[_group_num].trackers.end()) {
mem_tracker_limiter_pool[_group_num].trackers.erase(_tracker_limiter_group_it);
Expand Down
2 changes: 0 additions & 2 deletions be/src/vec/exprs/vexpr_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
#include <ostream>
#include <string>

#include "common/daemon.h"

// IWYU pragma: no_include <opentelemetry/common/threadlocal.h>
#include "common/compiler_util.h" // IWYU pragma: keep
#include "common/object_pool.h"
Expand Down

0 comments on commit 290a860

Please sign in to comment.