Skip to content

Commit

Permalink
[fix][mem tracker] Fix logout load task mem tracker dcheck fail (apac…
Browse files Browse the repository at this point in the history
…he#9943)

* fix tracker 0602

* fix format
  • Loading branch information
xinyiZzz authored and dataroaring committed Jun 7, 2022
1 parent 429a41d commit 3585fe6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions be/src/runtime/load_channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 8 additions & 3 deletions be/src/runtime/mem_tracker_task_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 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);
VLOG_FILE << "Deregister task memory tracker, task id: " << tid;
}
}
}

Expand Down

0 comments on commit 3585fe6

Please sign in to comment.