mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Attempt to fix inconsistent values in total memory tracker #3143
This commit is contained in:
parent
836c20b2d3
commit
dd88c092b7
@ -43,8 +43,7 @@ MemoryTracker::~MemoryTracker()
|
||||
* then memory usage of 'next' memory trackers will be underestimated,
|
||||
* because amount will be decreased twice (first - here, second - when real 'free' happens).
|
||||
*/
|
||||
if (auto value = amount.load(std::memory_order_relaxed))
|
||||
free(value);
|
||||
reset();
|
||||
}
|
||||
|
||||
|
||||
@ -170,7 +169,8 @@ void MemoryTracker::resetCounters()
|
||||
void MemoryTracker::reset()
|
||||
{
|
||||
if (!parent.load(std::memory_order_relaxed))
|
||||
CurrentMetrics::sub(metric, amount.load(std::memory_order_relaxed));
|
||||
if (auto value = amount.load(std::memory_order_relaxed))
|
||||
free(value);
|
||||
|
||||
resetCounters();
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ void ThreadStatus::detachQuery(bool exit_if_already_detached, bool thread_exits)
|
||||
|
||||
/// Detach from thread group
|
||||
performance_counters.setParent(&ProfileEvents::global_counters);
|
||||
memory_tracker.setParent(nullptr);
|
||||
memory_tracker.reset();
|
||||
query_context = nullptr;
|
||||
thread_group.reset();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user