From 09cb8fa005a726db45f5e07e9e3372ef2b8060a2 Mon Sep 17 00:00:00 2001 From: yiguolei Date: Tue, 14 Jul 2026 17:27:56 +0800 Subject: [PATCH] [bugfix](memory) should force refresh workload group's config when memlimit changed (#65542) ### What problem does this PR solve? Issue Number: close #xxx Related PR: #xxx Problem Summary: ### Release note None ### Check List (For Author) - Test - [ ] Regression test - [ ] Unit Test - [ ] Manual test (add detailed scripts or steps below) - [ ] No need to test or manual test. Explain why: - [ ] This is a refactor/code format and no logic has been changed. - [ ] Previous test can cover this change. - [ ] No code files have been changed. - [ ] Other reason - Behavior changed: - [ ] No. - [ ] Yes. - Does this need documentation? - [ ] No. - [ ] Yes. ### Check List (For Reviewer who merge this PR) - [ ] Confirm the release note - [ ] Confirm test cases - [ ] Confirm document - [ ] Add branch pick label --- .../runtime/workload_group/workload_group.cpp | 56 ++++++++----------- 1 file changed, 24 insertions(+), 32 deletions(-) diff --git a/be/src/runtime/workload_group/workload_group.cpp b/be/src/runtime/workload_group/workload_group.cpp index bdb48b25874e01..f289d29b2b39e9 100644 --- a/be/src/runtime/workload_group/workload_group.cpp +++ b/be/src/runtime/workload_group/workload_group.cpp @@ -153,38 +153,30 @@ void WorkloadGroup::check_and_update(const WorkloadGroupInfo& wg_info) { if (UNLIKELY(wg_info.id != _id)) { return; } - { - std::shared_lock rl {_mutex}; - if (LIKELY(wg_info.version <= _version)) { - return; - } - } - { - std::lock_guard wl {_mutex}; - if (wg_info.version > _version) { - _name = wg_info.name; - _version = wg_info.version; - _min_cpu_percent = wg_info.min_cpu_percent; - _max_cpu_percent = wg_info.max_cpu_percent; - _memory_limit = wg_info.memory_limit; - _min_memory_percent = wg_info.min_memory_percent; - _max_memory_percent = wg_info.max_memory_percent; - _scan_thread_num = wg_info.scan_thread_num; - _max_remote_scan_thread_num = wg_info.max_remote_scan_thread_num; - _min_remote_scan_thread_num = wg_info.min_remote_scan_thread_num; - _memory_low_watermark = wg_info.memory_low_watermark; - _memory_high_watermark = wg_info.memory_high_watermark; - _scan_bytes_per_second = wg_info.read_bytes_per_second; - _remote_scan_bytes_per_second = wg_info.remote_read_bytes_per_second; - _total_query_slot_count = wg_info.total_query_slot_count; - _slot_mem_policy = wg_info.slot_mem_policy; - if (_max_memory_percent > 0) { - _min_memory_limit = static_cast( - static_cast(_memory_limit * _min_memory_percent) / - _max_memory_percent); - } - } else { - return; + std::lock_guard wl {_mutex}; + // In serverless mode, user may modify cgroup's memory limit directly and workload group's config + // is not changed. So that we should update workload group's config ignore version. + if (wg_info.version > _version || + (wg_info.version == _version && _memory_limit != wg_info.memory_limit)) { + _name = wg_info.name; + _version = wg_info.version; + _min_cpu_percent = wg_info.min_cpu_percent; + _max_cpu_percent = wg_info.max_cpu_percent; + _memory_limit = wg_info.memory_limit; + _min_memory_percent = wg_info.min_memory_percent; + _max_memory_percent = wg_info.max_memory_percent; + _scan_thread_num = wg_info.scan_thread_num; + _max_remote_scan_thread_num = wg_info.max_remote_scan_thread_num; + _min_remote_scan_thread_num = wg_info.min_remote_scan_thread_num; + _memory_low_watermark = wg_info.memory_low_watermark; + _memory_high_watermark = wg_info.memory_high_watermark; + _scan_bytes_per_second = wg_info.read_bytes_per_second; + _remote_scan_bytes_per_second = wg_info.remote_read_bytes_per_second; + _total_query_slot_count = wg_info.total_query_slot_count; + _slot_mem_policy = wg_info.slot_mem_policy; + if (_max_memory_percent > 0) { + _min_memory_limit = static_cast( + static_cast(_memory_limit * _min_memory_percent) / _max_memory_percent); } } }