mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-14 10:22:10 +00:00
Merge pull request #73126 from ClickHouse/backport/24.9/73081
Backport #73081 to 24.9: Fix possible overestimate memory tracking
This commit is contained in:
commit
79b05b1222
@ -206,8 +206,6 @@ bool ThreadStatus::isQueryCanceled() const
|
|||||||
|
|
||||||
ThreadStatus::~ThreadStatus()
|
ThreadStatus::~ThreadStatus()
|
||||||
{
|
{
|
||||||
flushUntrackedMemory();
|
|
||||||
|
|
||||||
/// It may cause segfault if query_context was destroyed, but was not detached
|
/// It may cause segfault if query_context was destroyed, but was not detached
|
||||||
auto query_context_ptr = query_context.lock();
|
auto query_context_ptr = query_context.lock();
|
||||||
assert((!query_context_ptr && getQueryId().empty()) || (query_context_ptr && getQueryId() == query_context_ptr->getCurrentQueryId()));
|
assert((!query_context_ptr && getQueryId().empty()) || (query_context_ptr && getQueryId() == query_context_ptr->getCurrentQueryId()));
|
||||||
@ -218,6 +216,9 @@ ThreadStatus::~ThreadStatus()
|
|||||||
|
|
||||||
chassert(!check_current_thread_on_destruction || current_thread == this);
|
chassert(!check_current_thread_on_destruction || current_thread == this);
|
||||||
|
|
||||||
|
/// Flush untracked_memory **right before** switching the current_thread to avoid losing untracked_memory in deleter (detachFromGroup)
|
||||||
|
flushUntrackedMemory();
|
||||||
|
|
||||||
/// Only change current_thread if it's currently being used by this ThreadStatus
|
/// Only change current_thread if it's currently being used by this ThreadStatus
|
||||||
/// For example, PushingToViews chain creates and deletes ThreadStatus instances while running in the main query thread
|
/// For example, PushingToViews chain creates and deletes ThreadStatus instances while running in the main query thread
|
||||||
if (current_thread == this)
|
if (current_thread == this)
|
||||||
|
Loading…
Reference in New Issue
Block a user