Skip to content

Commit

Permalink
Attempt to fix inconsistent values in total memory tracker #3143
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-milovidov committed Sep 26, 2018
1 parent 836c20b commit dd88c09
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions dbms/src/Common/MemoryTracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}


Expand Down Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion dbms/src/Interpreters/ThreadStatusExt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit dd88c09

Please sign in to comment.