mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Avoid accounting memory from another mutation/merge
Before this path it was possible that one merge/mutation may account memory from another, due to ThreadStatus::untracked_memory. And this cause flakiness of 01200_mutations_memory_consumption.
This commit is contained in:
parent
fd38cbb0df
commit
8cc45bea7b
@ -34,6 +34,11 @@ MemoryTrackerThreadSwitcher::MemoryTrackerThreadSwitcher(MemoryTracker * memory_
|
||||
|
||||
prev_untracked_memory_limit = current_thread->untracked_memory_limit;
|
||||
current_thread->untracked_memory_limit = untracked_memory_limit;
|
||||
|
||||
/// Avoid accounting memory from another mutation/merge
|
||||
/// (NOTE: consider moving such code to ThreadFromGlobalPool and related places)
|
||||
prev_untracked_memory = current_thread->untracked_memory;
|
||||
current_thread->untracked_memory = 0;
|
||||
}
|
||||
|
||||
|
||||
@ -45,6 +50,7 @@ MemoryTrackerThreadSwitcher::~MemoryTrackerThreadSwitcher()
|
||||
background_thread_memory_tracker->setParent(background_thread_memory_tracker_prev_parent);
|
||||
|
||||
current_thread->untracked_memory_limit = prev_untracked_memory_limit;
|
||||
current_thread->untracked_memory = prev_untracked_memory;
|
||||
}
|
||||
|
||||
MergeListElement::MergeListElement(
|
||||
|
@ -68,6 +68,7 @@ private:
|
||||
MemoryTracker * background_thread_memory_tracker;
|
||||
MemoryTracker * background_thread_memory_tracker_prev_parent = nullptr;
|
||||
UInt64 prev_untracked_memory_limit;
|
||||
UInt64 prev_untracked_memory;
|
||||
};
|
||||
|
||||
using MemoryTrackerThreadSwitcherPtr = std::unique_ptr<MemoryTrackerThreadSwitcher>;
|
||||
|
Loading…
Reference in New Issue
Block a user