Skip to content

Commit

Permalink
[BugFix] Fix thread local variable initialization problem (#50899)
Browse files Browse the repository at this point in the history
Signed-off-by: trueeyu <[email protected]>
  • Loading branch information
trueeyu committed Sep 18, 2024
1 parent d4add5c commit 2d3ee0b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions be/src/runtime/current_thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ inline thread_local MemTracker* tls_exceed_mem_tracker = nullptr;
// you can add a new check tracker by set up `tls_singleton_check_mem_tracker`.
inline thread_local MemTracker* tls_singleton_check_mem_tracker = nullptr;
inline thread_local bool tls_is_thread_status_init = false;
inline thread_local bool tls_is_catched = false;

class CurrentThread {
private:
Expand Down Expand Up @@ -283,13 +284,13 @@ class CurrentThread {
tls_singleton_check_mem_tracker = mem_tracker;
}

bool set_is_catched(bool is_catched) {
bool old = _is_catched;
_is_catched = is_catched;
static bool set_is_catched(bool is_catched) {
bool old = tls_is_catched;
tls_is_catched = is_catched;
return old;
}

bool is_catched() const { return _is_catched; }
static bool is_catched() { return tls_is_catched; }

void mem_consume(int64_t size) {
_mem_cache_manager.consume(size);
Expand Down Expand Up @@ -371,7 +372,6 @@ class CurrentThread {
TUniqueId _fragment_instance_id;
std::string _custom_coredump_msg{};
int32_t _driver_id = 0;
bool _is_catched = false;
bool _check = true;
bool _reserve_mod = false;
};
Expand Down
2 changes: 1 addition & 1 deletion be/src/service/mem_hook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
} while (0)
#define SET_EXCEED_MEM_TRACKER() \
starrocks::tls_exceed_mem_tracker = starrocks::GlobalEnv::GetInstance()->process_mem_tracker()
#define IS_BAD_ALLOC_CATCHED() starrocks::tls_thread_status.is_catched()
#define IS_BAD_ALLOC_CATCHED() starrocks::tls_is_catched
#else
std::atomic<int64_t> g_mem_usage(0);
#define MEMORY_CONSUME_SIZE(size) g_mem_usage.fetch_add(size)
Expand Down

0 comments on commit 2d3ee0b

Please sign in to comment.