From ee9ecf3f625390ba7359e8f4a98cf7489ab53472 Mon Sep 17 00:00:00 2001 From: jacktengg Date: Tue, 14 Jan 2025 15:12:20 +0800 Subject: [PATCH] fix --- be/src/pipeline/pipeline_task.cpp | 5 +++-- be/src/runtime/query_context.h | 5 ++++- be/src/runtime/runtime_state.cpp | 5 ----- be/src/runtime/runtime_state.h | 2 -- be/src/vec/exec/scan/scanner_scheduler.cpp | 2 +- 5 files changed, 8 insertions(+), 11 deletions(-) diff --git a/be/src/pipeline/pipeline_task.cpp b/be/src/pipeline/pipeline_task.cpp index 9aa968e6f20376..e09da6ab742380 100644 --- a/be/src/pipeline/pipeline_task.cpp +++ b/be/src/pipeline/pipeline_task.cpp @@ -412,7 +412,8 @@ Status PipelineTask::execute(bool* eos) { const auto reserve_size = _root->get_reserve_mem_size(_state); _root->reset_reserve_mem_size(_state); - if (workload_group && _state->enable_reserve_memory() && reserve_size > 0) { + if (workload_group && _state->get_query_ctx()->enable_reserve_memory() && + reserve_size > 0) { auto st = thread_context()->try_reserve_memory(reserve_size); COUNTER_UPDATE(_memory_reserve_times, 1); @@ -445,7 +446,7 @@ Status PipelineTask::execute(bool* eos) { DEFER_RELEASE_RESERVED(); COUNTER_UPDATE(_memory_reserve_times, 1); auto workload_group = _state->get_query_ctx()->workload_group(); - if (_state->enable_reserve_memory() && workload_group && + if (_state->get_query_ctx()->enable_reserve_memory() && workload_group && !(wake_up_early() || _dry_run)) { const auto sink_reserve_size = _sink->get_reserve_mem_size(_state, *eos); status = sink_reserve_size != 0 diff --git a/be/src/runtime/query_context.h b/be/src/runtime/query_context.h index 615dcda8c8be94..954369e29fa55f 100644 --- a/be/src/runtime/query_context.h +++ b/be/src/runtime/query_context.h @@ -311,7 +311,10 @@ class QueryContext : public std::enable_shared_from_this { void disable_reserve_memory() { _enable_reserve_memory = false; } - bool enable_reserve_memory() { return _enable_reserve_memory; } + bool enable_reserve_memory() const { + return _query_options.__isset.enable_reserve_memory && + _query_options.enable_reserve_memory && _enable_reserve_memory; + } void update_paused_reason(const Status& st) { std::lock_guard l(_paused_mutex); diff --git a/be/src/runtime/runtime_state.cpp b/be/src/runtime/runtime_state.cpp index 781bb434b5a199..c4def4c05137ea 100644 --- a/be/src/runtime/runtime_state.cpp +++ b/be/src/runtime/runtime_state.cpp @@ -540,9 +540,4 @@ std::vector> RuntimeState::build_pipeline_profil } return _pipeline_id_to_profile; } - -bool RuntimeState::enable_reserve_memory() const { - return _query_options.__isset.enable_reserve_memory && _query_options.enable_reserve_memory && - _query_ctx->enable_reserve_memory(); -} } // end namespace doris diff --git a/be/src/runtime/runtime_state.h b/be/src/runtime/runtime_state.h index 57f673af9bf03c..6c2d0918d8b722 100644 --- a/be/src/runtime/runtime_state.h +++ b/be/src/runtime/runtime_state.h @@ -555,8 +555,6 @@ class RuntimeState { return _query_options.__isset.enable_force_spill && _query_options.enable_force_spill; } - bool enable_reserve_memory() const; - int64_t spill_min_revocable_mem() const { if (_query_options.__isset.min_revocable_mem) { return std::max(_query_options.min_revocable_mem, (int64_t)1); diff --git a/be/src/vec/exec/scan/scanner_scheduler.cpp b/be/src/vec/exec/scan/scanner_scheduler.cpp index 8a2387cc69e2a6..530d9371059b72 100644 --- a/be/src/vec/exec/scan/scanner_scheduler.cpp +++ b/be/src/vec/exec/scan/scanner_scheduler.cpp @@ -303,7 +303,7 @@ void ScannerScheduler::_scanner_scan(std::shared_ptr ctx, if (first_read) { free_block = ctx->get_free_block(first_read); } else { - if (state->enable_reserve_memory()) { + if (state->get_query_ctx()->enable_reserve_memory()) { size_t block_avg_bytes = scanner->get_block_avg_bytes(); auto st = thread_context()->try_reserve_memory(block_avg_bytes); if (!st.ok()) {