mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 01:25:21 +00:00
Backport #64844 to 24.3: Fix untracked memory in MemoryTrackerSwitcher
This commit is contained in:
parent
b4086b6260
commit
6e16f6aa20
@ -15,6 +15,7 @@ struct MemoryTrackerSwitcher
|
||||
return;
|
||||
|
||||
auto * thread_tracker = CurrentThread::getMemoryTracker();
|
||||
|
||||
prev_untracked_memory = current_thread->untracked_memory;
|
||||
prev_memory_tracker_parent = thread_tracker->getParent();
|
||||
|
||||
@ -31,8 +32,10 @@ struct MemoryTrackerSwitcher
|
||||
CurrentThread::flushUntrackedMemory();
|
||||
auto * thread_tracker = CurrentThread::getMemoryTracker();
|
||||
|
||||
current_thread->untracked_memory = prev_untracked_memory;
|
||||
/// It is important to set untracked memory after the call of
|
||||
/// 'setParent' because it may flush untracked memory to the wrong parent.
|
||||
thread_tracker->setParent(prev_memory_tracker_parent);
|
||||
current_thread->untracked_memory = prev_untracked_memory;
|
||||
}
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user