From 601c80fb6e7c47626be2a5750229975f30ba89a1 Mon Sep 17 00:00:00 2001 From: Xinyi Zou Date: Thu, 2 Jun 2022 17:53:09 +0800 Subject: [PATCH 1/2] fix tracker 0602 --- be/src/runtime/load_channel.cpp | 4 ++-- be/src/runtime/mem_tracker_task_pool.cpp | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/be/src/runtime/load_channel.cpp b/be/src/runtime/load_channel.cpp index 55038e2742ec88..1c270a34737833 100644 --- a/be/src/runtime/load_channel.cpp +++ b/be/src/runtime/load_channel.cpp @@ -34,8 +34,8 @@ LoadChannel::LoadChannel(const UniqueId& load_id, int64_t mem_limit, int64_t tim _is_vec(is_vec) { _mem_tracker = MemTracker::create_tracker( mem_limit, "LoadChannel:tabletId=" + _load_id.to_string(), - ExecEnv::GetInstance()->task_pool_mem_tracker_registry()->get_task_mem_tracker( - _load_id.to_string()), + ExecEnv::GetInstance()->task_pool_mem_tracker_registry()->register_load_mem_tracker( + _load_id.to_string(), mem_limit), MemTrackerLevel::TASK); // _last_updated_time should be set before being inserted to // _load_channels in load_channel_mgr, or it may be erased diff --git a/be/src/runtime/mem_tracker_task_pool.cpp b/be/src/runtime/mem_tracker_task_pool.cpp index 132b47f57356ab..bd3bafee52a694 100644 --- a/be/src/runtime/mem_tracker_task_pool.cpp +++ b/be/src/runtime/mem_tracker_task_pool.cpp @@ -89,9 +89,14 @@ void MemTrackerTaskPool::logout_task_mem_tracker() { } } for (auto tid : expired_tasks) { - DCHECK(_task_mem_trackers[tid].use_count() == 1); - _task_mem_trackers.erase(tid); - VLOG_FILE << "Deregister task memory tracker, task id: " << tid; + // This means that after all RuntimeState is destructed, + // there are still task mem trackers that are get or register. + // The only known case: after an import task ends all fragments on a BE,`tablet_writer_open` is still + // called to create a channel, and the load task tracker will be re-registered in the channel open. + if (_task_mem_trackers[tid].use_count() == 1) { + _task_mem_trackers.erase(tid); + VLOG_FILE << "Deregister task memory tracker, task id: " << tid; + } } } From 7c0d99d67a0694fde8f13816f3ceb0a51c90ccff Mon Sep 17 00:00:00 2001 From: Xinyi Zou Date: Thu, 2 Jun 2022 18:01:34 +0800 Subject: [PATCH 2/2] fix format --- be/src/runtime/mem_tracker_task_pool.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/be/src/runtime/mem_tracker_task_pool.cpp b/be/src/runtime/mem_tracker_task_pool.cpp index bd3bafee52a694..551d904111ce01 100644 --- a/be/src/runtime/mem_tracker_task_pool.cpp +++ b/be/src/runtime/mem_tracker_task_pool.cpp @@ -91,7 +91,7 @@ void MemTrackerTaskPool::logout_task_mem_tracker() { for (auto tid : expired_tasks) { // This means that after all RuntimeState is destructed, // there are still task mem trackers that are get or register. - // The only known case: after an import task ends all fragments on a BE,`tablet_writer_open` is still + // The only known case: after an load task ends all fragments on a BE,`tablet_writer_open` is still // called to create a channel, and the load task tracker will be re-registered in the channel open. if (_task_mem_trackers[tid].use_count() == 1) { _task_mem_trackers.erase(tid);