File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed
Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -216,8 +216,6 @@ size_t ThreadStatus::getNextPipelineProcessorIndex() const
216216
217217ThreadStatus::~ThreadStatus ()
218218{
219- flushUntrackedMemory ();
220-
221219 // / It may cause segfault if query_context was destroyed, but was not detached
222220 auto query_context_ptr = query_context.lock ();
223221 assert ((!query_context_ptr && getQueryId ().empty ()) || (query_context_ptr && getQueryId () == query_context_ptr->getCurrentQueryId ()));
@@ -228,6 +226,9 @@ ThreadStatus::~ThreadStatus()
228226
229227 chassert (!check_current_thread_on_destruction || current_thread == this );
230228
229+ // / Flush untracked_memory **right before** switching the current_thread to avoid losing untracked_memory in deleter (detachFromGroup)
230+ flushUntrackedMemory ();
231+
231232 // / Only change current_thread if it's currently being used by this ThreadStatus
232233 // / For example, PushingToViews chain creates and deletes ThreadStatus instances while running in the main query thread
233234 if (current_thread == this )
You can’t perform that action at this time.
0 commit comments