Skip to content

Commit

Permalink
[fix](memory) Fix thread context not initialized in MacOS (apache#32570)
Browse files Browse the repository at this point in the history
  • Loading branch information
xinyiZzz authored Mar 21, 2024
1 parent 425cb6b commit b3e397f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
6 changes: 5 additions & 1 deletion be/src/olap/rowset/segment_v2/page_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,11 @@ Status PageIO::read_and_decompress_page(const PageReadOptions& opts, PageHandle*
if (opts.use_page_cache && cache) {
page_mem_tracker = cache->mem_tracker(opts.type);
} else {
page_mem_tracker = thread_context()->thread_mem_tracker_mgr->limiter_mem_tracker();
if (is_thread_context_init()) {
page_mem_tracker = thread_context()->thread_mem_tracker_mgr->limiter_mem_tracker();
} else {
page_mem_tracker = ExecEnv::GetInstance()->orphan_mem_tracker();
}
}

// hold compressed page at first, reset to decompressed page later
Expand Down
9 changes: 6 additions & 3 deletions be/src/vec/common/allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@

template <bool clear_memory_, bool mmap_populate, bool use_mmap>
void Allocator<clear_memory_, mmap_populate, use_mmap>::sys_memory_check(size_t size) const {
if (doris::is_thread_context_init() && doris::thread_context()->skip_memory_check != 0) {
if (!doris::is_thread_context_init()) {
return;
}
if (doris::thread_context()->skip_memory_check != 0) {
return;
}
if (doris::MemTrackerLimiter::sys_mem_exceed_limit_check(size)) {
Expand Down Expand Up @@ -132,10 +135,10 @@ void Allocator<clear_memory_, mmap_populate, use_mmap>::sys_memory_check(size_t

template <bool clear_memory_, bool mmap_populate, bool use_mmap>
void Allocator<clear_memory_, mmap_populate, use_mmap>::memory_tracker_check(size_t size) const {
if (doris::is_thread_context_init() && doris::thread_context()->skip_memory_check != 0) {
if (!doris::is_thread_context_init()) {
return;
}
if (!doris::is_thread_context_init()) {
if (doris::thread_context()->skip_memory_check != 0) {
return;
}
auto st = doris::thread_context()->thread_mem_tracker()->check_limit(size);
Expand Down

0 comments on commit b3e397f

Please sign in to comment.