Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
yiguolei committed Jan 6, 2025
1 parent bc69a21 commit 730c0f5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions be/src/runtime/memory/mem_tracker_limiter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ std::shared_ptr<MemTrackerLimiter> MemTrackerLimiter::create_shared(MemTrackerLi
auto tracker = std::make_shared<MemTrackerLimiter>(type, label, byte_limit);
// Write tracker is only used to tracker the size, so limit == -1
auto write_tracker = std::make_shared<MemTrackerLimiter>(type, "Memtable" + label, -1);
// Memtable has a separate logic to deal with memory flush, so that should not check the limit in memtracker.
write_tracker->set_enable_reserve_memory(true);
tracker->_write_tracker.swap(write_tracker);
#ifndef BE_TEST
DCHECK(ExecEnv::tracking_memory());
Expand Down
6 changes: 5 additions & 1 deletion be/src/runtime/memory/mem_tracker_limiter.h
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,11 @@ inline Status MemTrackerLimiter::check_limit(int64_t bytes) {
return Status::OK();
}

// check limit should ignore memtable size, because it is treated as a cache
// If reserve not enabled, then should check limit here to kill the query when limit exceed.
// For insert into select or pure load job, its memtable is accounted in a seperate memtracker limiter,
// and its reserve is set to true. So that it will not reach this logic.
// Only query and load job has exec_mem_limit and the _limit > 0, other memtracker limiter's _limit is -1 so
// it will not take effect.
if (_limit > 0 && consumption() + bytes > _limit) {
return Status::MemoryLimitExceeded(fmt::format("failed alloc size {}, {}",
MemCounter::print_bytes(bytes),
Expand Down

0 comments on commit 730c0f5

Please sign in to comment.