This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 6595dedc421 [test](be) Set the memory water marks that
WorkloadGroupManagerTest relies on (#71201)
6595dedc421 is described below
commit 6595dedc421734e88ce152c79ce29159882e1efd
Author: Mingyu Chen (Rayner) <[email protected]>
AuthorDate: Tue Dec 1 15:04:58 2026 +0800
[test](be) Set the memory water marks that WorkloadGroupManagerTest relies
on (#71201)
### Background
`GlobalMemoryArbitrator::is_exceed_soft_mem_limit(bytes)` reports
process memory pressure when the process memory plus `bytes` reaches the
soft limit, or when the system available memory minus `bytes` falls
below `MemInfo::sys_mem_available_warning_water_mark()`; the hard-limit
check uses the low water mark the same way. `MemInfo::init()` sets both
water marks only on Linux, and only when `/proc/meminfo` has
`MemAvailable`; otherwise, as on macOS, they stay `INT64_MIN` and that
side of the checks never fires. The `PROCESS_MEMORY_EXCEEDED` cases of
`WorkloadGroupManagerTest` (#67845) drive both sides of these checks.
### What problem does this PR solve?
Issue Number: None
Related PR: #67845 (added the case)
PR Type: Test
Problem Summary:
`process_mem_exceeded_resumes_when_reservation_fits_sys_mem_available`
sets the system available memory 16 MiB above the runner's warning water
mark, to check that a paused query resumes once its recorded 1 KiB
reservation fits although a 32 MiB probe would not, and first asserts
that this water mark is positive. On macOS it is `INT64_MIN`, so the
case fails on every local run:
```
Expected: (MemInfo::sys_mem_available_warning_water_mark()) > (0), actual:
-9223372036854775808 vs 0
```
A Linux runner whose `/proc/meminfo` has no `MemAvailable`, or whose low
water mark computes to 0 (`mem_limit` at or above the physical memory),
would fail the same way. The fixture now sets both water marks itself
(512 MiB and 1 GiB) in SetUp and restores them in TearDown, as it
already does for the memory limits and the system available memory, and
the case is written against that value. Only test code changes.
### Details
- **Failure:** macOS arm64, ASAN, `run-be-ut.sh --run
--filter='WorkloadGroupManagerTest.*'` at master `290b8adce77`: 51 of 52
cases pass and this one fails at the assertion above, on every run. No
CI job runs the BE unit tests on macOS
(`.github/workflows/be-ut-mac.yml` only compiles the BE), so only local
runs on a Mac show it; the Linux BE UT pipeline passes.
- **Cause:** the environment: the case uses the water marks that
`MemInfo::init()` computed from the runner, and the macOS
`MemInfo::init()` computes none.
- **Stability evidence:** the failure is deterministic, so the evidence
is a run before and after the change plus a mutation, on macOS arm64
with ASAN. With the change all 52 cases pass, also in 20 shuffled
iterations (`--gtest_repeat=20 --gtest_shuffle`). The case still catches
the regression it was written for: when the resume checks of
`WorkloadGroupMgr` test `max(reservation, 32 MiB)`, the probe #67845
replaced, the case fails at `_assert_resumed` (the query is cancelled
after its 60 s wait), as does its soft-limit sibling; before the change
it failed at the water mark assertion whatever the code did.
### Testing
- macOS arm64, ASAN, `run-be-ut.sh --run
--filter='WorkloadGroupManagerTest.*'`: at master `290b8adce77` 51
passed and this case failed; with this PR 52 passed, also in 20 shuffled
iterations.
- The mutation above, applied locally and reverted: this case and
`process_mem_exceeded_resumes_when_reservation_fits_soft_limit` fail,
the other 50 cases pass.
- Linux: not run locally; the BE UT pipeline runs this suite.
### Notes for Reviewers
- The water marks are written directly
(`MemInfo::_s_sys_mem_available_low_water_mark` and
`_s_sys_mem_available_warning_water_mark`): `doris_be_test` is compiled
with `-fno-access-control`, and `parse_util_test.cpp` already sets
`MemInfo::_s_physical_mem` this way. The alternative was another
`set_*_for_test` hook in `util/mem_info.h`, next to the existing ones;
about 900 objects of the BE UT build depend on that header and would be
rebuilt for a test-only change.
- The removed
`ASSERT_GT(MemInfo::sys_mem_available_warning_water_mark(), 0)` checked
the runner; the `ASSERT_TRUE(is_exceed_soft_mem_limit(32 MiB))` that
follows still shows that the water mark is in effect, since the process
limits have their whole headroom at that point.
- The other 51 cases keep the system available memory at `INT64_MAX / 2`
(SetUp and `_relieve_process_mem_limit()`), far above any water mark, so
the fixed water marks change none of their checks.
- branch-4.2 has the same case (#70432).
---
.../workload_group/workload_group_manager_test.cpp | 33 ++++++++++++++++------
1 file changed, 25 insertions(+), 8 deletions(-)
diff --git a/be/test/runtime/workload_group/workload_group_manager_test.cpp
b/be/test/runtime/workload_group/workload_group_manager_test.cpp
index 5e8dc9deed2..6253ab53c99 100644
--- a/be/test/runtime/workload_group/workload_group_manager_test.cpp
+++ b/be/test/runtime/workload_group/workload_group_manager_test.cpp
@@ -69,6 +69,12 @@ static constexpr int64_t kProcessMemLimitForWg = 1024L *
1024 * 1000;
// System available memory far above the warning water mark, so that only the
process memory
// limits decide the process memory predicates unless a case lowers it on
purpose.
static constexpr int64_t kLargeSysMemAvailable =
std::numeric_limits<int64_t>::max() / 2;
+// System available memory water marks. MemInfo::init() derives them from the
runner, and only
+// when /proc/meminfo has MemAvailable: on macOS, or on a Linux without it,
both stay INT64_MIN and
+// no system available memory is ever below them. The warning water mark is
twice the low one, as
+// MemInfo::init() sets them.
+static constexpr int64_t kSysMemAvailableLowWaterMark = 1024L * 1024 * 512;
+static constexpr int64_t kSysMemAvailableWarningWaterMark =
kSysMemAvailableLowWaterMark * 2;
static constexpr int64_t kProcessPausedReserveSize = 1024L;
class WorkloadGroupManagerTest : public testing::Test {
@@ -77,11 +83,18 @@ protected:
void SetUp() override {
_original_mem_limit = MemInfo::mem_limit();
_original_soft_mem_limit = MemInfo::soft_mem_limit();
- // The process memory predicates also depend on the system available
memory, which is
- // read from the runner otherwise: a runner below the water marks
reports pressure before
- // a case sets any process memory limit.
+ // The process memory predicates also depend on the system available
memory and its
+ // water marks, which are read from the runner otherwise: a runner
below the water marks
+ // reports pressure before a case sets any process memory limit, and a
runner without
+ // water marks never reports it. The water marks have no test setter;
doris_be_test is
+ // built with -fno-access-control, so they are written directly.
_original_sys_mem_available =
MemInfo::set_sys_mem_available_for_test(kLargeSysMemAvailable);
+ _original_sys_mem_available_low_water_mark =
MemInfo::sys_mem_available_low_water_mark();
+ _original_sys_mem_available_warning_water_mark =
+ MemInfo::sys_mem_available_warning_water_mark();
+ MemInfo::_s_sys_mem_available_low_water_mark =
kSysMemAvailableLowWaterMark;
+ MemInfo::_s_sys_mem_available_warning_water_mark =
kSysMemAvailableWarningWaterMark;
_wg_manager = std::make_unique<WorkloadGroupMgr>();
// generate a unique test directory to avoid conflicts between
parallel runs
std::ostringstream _oss;
@@ -128,6 +141,9 @@ protected:
MemInfo::set_mem_limit_for_test(_original_mem_limit);
MemInfo::set_soft_mem_limit_for_test(_original_soft_mem_limit);
MemInfo::set_sys_mem_available_for_test(_original_sys_mem_available);
+ MemInfo::_s_sys_mem_available_low_water_mark =
_original_sys_mem_available_low_water_mark;
+ MemInfo::_s_sys_mem_available_warning_water_mark =
+ _original_sys_mem_available_warning_water_mark;
GlobalMemoryArbitrator::reset_refresh_interval_memory_growth();
_wg_manager.reset();
ExecEnv::GetInstance()->spill_file_mgr()->stop();
@@ -224,8 +240,9 @@ private:
// The process memory predicates are controlled from both sides in the
following helpers:
// the process memory usage is the vm_rss of PerfCounters (never refreshed
in a unit test)
// plus the memory growth since the last refresh, which the helpers set;
the system available
- // memory is set in SetUp far above the water marks. The process memory
limit is kept at
- // kProcessMemLimitForWg, which refresh_memory_usage() derives the
workload group limits from.
+ // memory is set in SetUp far above the water marks, which SetUp fixes as
well. The process
+ // memory limit is kept at kProcessMemLimitForWg, which
refresh_memory_usage() derives the
+ // workload group limits from.
// Process soft memory limit is exceeded, hard memory limit is not.
static void _exceed_process_soft_mem_limit() {
@@ -331,6 +348,8 @@ private:
int64_t _original_mem_limit {0};
int64_t _original_soft_mem_limit {0};
int64_t _original_sys_mem_available {0};
+ int64_t _original_sys_mem_available_low_water_mark {0};
+ int64_t _original_sys_mem_available_warning_water_mark {0};
std::vector<std::pair<std::shared_ptr<QueryContext>, int64_t>>
_consumed_memory;
};
@@ -1689,9 +1708,7 @@ TEST_F(WorkloadGroupManagerTest,
// The process limits have their whole headroom, only the system available
memory is close
// to the warning water mark: 16 MiB above it.
_relieve_process_mem_limit();
- ASSERT_GT(MemInfo::sys_mem_available_warning_water_mark(), 0);
-
MemInfo::set_sys_mem_available_for_test(MemInfo::sys_mem_available_warning_water_mark()
+
- 1024L * 1024 * 16);
+ MemInfo::set_sys_mem_available_for_test(kSysMemAvailableWarningWaterMark +
1024L * 1024 * 16);
ASSERT_FALSE(GlobalMemoryArbitrator::is_exceed_soft_mem_limit(kProcessPausedReserveSize));
ASSERT_TRUE(GlobalMemoryArbitrator::is_exceed_soft_mem_limit(1024L * 1024
* 32));
_backdate_paused_query(wg, config::spill_in_paused_queue_timeout_ms + 1);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]