From 67c7e0a7e725e7b656ed696d9548e673670f52e5 Mon Sep 17 00:00:00 2001 From: Xinyi Zou Date: Tue, 6 Aug 2024 18:14:17 +0800 Subject: [PATCH] 2 --- be/src/runtime/thread_context.h | 2 +- be/src/vec/common/allocator.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/be/src/runtime/thread_context.h b/be/src/runtime/thread_context.h index 11be7f7ddbe5343..7e42408f5afb3c0 100644 --- a/be/src/runtime/thread_context.h +++ b/be/src/runtime/thread_context.h @@ -313,7 +313,7 @@ static ThreadContext* thread_context(bool allow_return_null = false) { // in bthread // bthread switching pthread may be very frequent, remember not to use lock or other time-consuming operations. auto* bthread_context = static_cast(bthread_getspecific(btls_key)); - DCHECK(bthread_context != nullptr); + DCHECK(bthread_context != nullptr && bthread_context->thread_local_handle_count > 0); return bthread_context; } if (allow_return_null) { diff --git a/be/src/vec/common/allocator.cpp b/be/src/vec/common/allocator.cpp index 2bd0fd190b8d085..b1951f9cf445ca3 100644 --- a/be/src/vec/common/allocator.cpp +++ b/be/src/vec/common/allocator.cpp @@ -220,8 +220,8 @@ template ::release_memory( size_t size) const { doris::ThreadContext* thread_context = doris::thread_context(true); - DCHECK(_tracker); - if (thread_context && thread_context->thread_mem_tracker()->label() == _tracker->label()) { + if (thread_context) { + DCHECK(!_tracker || thread_context->thread_mem_tracker()->label() == _tracker->label()); RELEASE_THREAD_MEM_TRACKER(size); } else { _tracker->release(size);