Merge pull request #66230 from ClickHouse/chesema-peak-threads-usage

fix peak_threads_usage
This commit is contained in:
Sema Checherinda 2024-07-09 10:32:30 +00:00 committed by GitHub
commit 186e690fa6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -233,7 +233,8 @@ void ThreadStatus::attachToGroupImpl(const ThreadGroupPtr & thread_group_)
{
/// Attach or init current thread to thread group and copy useful information from it
thread_group = thread_group_;
thread_group->linkThread(thread_id);
if (!internal_thread)
thread_group->linkThread(thread_id);
performance_counters.setParent(&thread_group->performance_counters);
memory_tracker.setParent(&thread_group->memory_tracker);
@ -269,7 +270,8 @@ void ThreadStatus::detachFromGroup()
/// Extract MemoryTracker out from query and user context
memory_tracker.setParent(&total_memory_tracker);
thread_group->unlinkThread();
if (!internal_thread)
thread_group->unlinkThread();
thread_group.reset();