Repository navigation
Reserve host memory for the CI runner agent in the stress and upgrade jobs - #118057
alexey-milovidov merged 2 commits into
Conversation
… jobs get_run_command builds the stress container with no --memory, and common_stress_job_config has no run_in_docker, so the job script runs on the runner host and launches a container that only the host bounds. Inside, configure_limits sets max_server_memory_usage_to_ram_ratio=0.8 and states that this is safe because "the total server memory usage is capped to the memory usage of the whole cgroup", a cap this call site never creates. getMemoryAmountOrZero takes min(physical RAM, cgroups v2 limit), so with no --memory the server sizes itself from the whole host, and its runtime dynamic limit tracks host availability rather than a leaf. The starved process is then the runner agent, which lives outside the container, so GitHub tears the job down before praktika can write a result: status ERROR, empty info, links=[], and no CI DB rows at all. A real crash or sanitizer report in such a run is lost, which is why this is worth fixing. Measured on Stress test (arm_asan_ubsan), job 100462891406, where configure_limits runs under set -x and prints its own inputs: total_mem=66198712320 (61.65 GiB of host RAM) with ratio 0.8, so the server ceiling was 49.32 GiB on a host that also had to run the agent. From 00:15:52Z the harness's own trivial statements were refused with 241, including bare SYSTEM STOP VIEWS and a LIMIT 1 read of system.mutations, which no per-query or per-user limit can explain. Runner timestamps then jump 19m44s while the lines arriving at the far end carry inner harness stamps from inside that gap, so the process was alive and only its output was not being drained. CI DB holds 0 rows for that check while the same commit carries 258,113 rows and nine sibling stress variants that each reported. I add --memory=Utils.physical_memory() - RUNNER_MEMORY_RESERVE, reusing the shape, the constant name and the 8 GiB of the merged fuzzer fix in ci/jobs/ast_fuzzer_job.py: that change measured 4.6 GiB of host headroom left at failure and chose 8 GiB because 4.6 was not enough. A kernel bound holds whatever the server, gdb and the clients do, and the launcher stays on the host, so an in-container kill still publishes a result. The value is computed at runtime, so it adapts per runner pool with nothing hard-coded. get_run_command is the single container call site for three job families, all of which gain the bound: Stress test (*), Stress test (amd_cfi) via cfi_stress_job, and Upgrade check (*), whose upgrade_job.py imports run_stress_test and only swaps the run script. That is 35 job instances across MasterCI, PR, ReleaseBranchCI and WeeklyCFI. Validated in the clickhouse/stress-test image with this job's exact flags, including --privileged, against a control that removes only --memory. With the cap, the container's memory.max equals the byte value passed, a plain 12 GiB allocation is SIGKILLed by the kernel, and a query the server refuses reports a maximum: scaled from the cap rather than from the host. Without it, memory.max reads max, the same allocation completes, and the same query passes a host-derived ceiling. No ci/defs/ change is needed, and praktika yaml leaves .github/workflows/ unchanged; stress_job.py is already in the digest include_paths of both affected job configs. The server ceiling drops 49.32 to 42.92 GiB on that runner, 12.98%, while the container keeps about 10.73 GiB inside for gdb and clients and 8 GiB is reserved outside for the agent. So stress runs meet MEMORY_LIMIT_EXCEEDED slightly sooner, and an overshoot becomes an in-container OOM kill, which the job reports, instead of a lost runner, which it cannot. max_memory_usage_for_user is read from /proc/meminfo, which Docker does not namespace, so it stays 18.50 GiB and remains below the new ceiling. keeper_stress_job was already capped with KEEPER_DIND_MEM and is untouched. The libFuzzer and vector-search containers are also uncapped, but I have no runner-loss observation for either, so they are left alone here. Co-Authored-By: Claude Opus 5 <[email protected]>
Internal second-model reviewAn independent cold review plus a second-model gate ran over this diff before publishing. 💡 The blast radius line now reads five workflows, not four:
💡 An overshoot after this change lands as an in-container kill, and |
|
Workflow [PR], commit [6b10e20] Summary: ✅ AI ReviewSummaryThis PR adds a shared Final Verdict✅ No new findings in the current diff. |
|
cc @leshikus, could you review this? |
…unner reserve get_run_command subtracted RUNNER_MEMORY_RESERVE from the visible RAM and passed the result straight to docker run --memory, with nothing checking the sign. The CI pools these jobs run on are amd-medium and arm-medium, measured at 61.65 GiB, so the subtraction is never near zero there, but the same file is a documented local entrypoint (python -m ci.praktika run "<JOB_NAME>"), where a smaller host reaches it. Measured with docker 29.5.1 on cgroups v2: --memory=-401154048 is rejected with exit 125 and "invalid size", while --memory=0 is accepted and the container's memory.max reads "max", so a host at exactly the reserve silently produced the uncapped container this change exists to prevent. Clamping at zero, as INTEGRATION_NESTED_BUDGET does in ci/defs/job_configs.py, is wrong here: that value is read by docker_in_docker.sh's validator, where zero is a refusal, not by docker, where it means no limit. So this raises, naming the host figure and the reserve. The value emitted on an adequately sized host is unchanged. On a 755.49 GiB box both code paths still carry exactly one --memory token holding physical_memory() - RUNNER_MEMORY_RESERVE, and a pristine-tree control taken by patch file agrees; at 7.63 GiB and at exactly 8 GiB that control emits -401154048 and 0, where this raises instead. Co-Authored-By: Claude Opus 5 <[email protected]>
|
Holding this one until the ceiling question is settled, because the fuzzer version of exactly this #116782 applied this same Here the arithmetic is the same shape and slightly worse: ratio 0.8 on the 61.65 GiB host takes the The host reserve itself is still worth having; it is the uncompensated ceiling that is the problem. |
|
Thanks. The hold was mine, so your approval settles it: the hold is released, and CI is green on I will watch |
|
Closing the watch I promised above: the memory-cgroup kills that |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Bound the stress test and upgrade check containers so a run cannot exhaust the CI runner host.
Description
Related: #116782
Related: #111892
Stress test (arm_asan_ubsan)on #116485 published nothing: praktika reportedERRORwithlinks=[], and CI DB holds 0 rows for it while the same commit carries 258,113 rows and ninesibling variants that each reported.
Report,
job log.
get_run_commandpasses no--memory, andcommon_stress_job_confighas norun_in_docker, so thecontainer is bounded only by the host.
configure_limitssetsmax_server_memory_usage_to_ram_ratio=0.8and calls that safe because "the total server memory usageis capped to the memory usage of the whole cgroup", a cap this call site never creates. Its log shows
total_mem=66198712320(61.65 GiB of host RAM), so the server's ceiling was 49.32 GiB on a host thatalso runs the agent. From 00:15:52Z its own trivial statements were refused with 241
(
SYSTEM STOP VIEWS, aLIMIT 1read ofsystem.mutations). Runner timestamps then jump 19m44swhile the lines arriving at the far end carry inner stamps from inside that gap: the process was
alive and only its output was not drained. GitHub then cancelled the job.
I add
--memory=Utils.physical_memory() - RUNNER_MEMORY_RESERVE, in the shape and with the 8 GiB of#116782. A kernel bound holds whatever the server,
gdband the clients do, and the launcher stayson the host, so an in-container kill still publishes a result.
This is the single container call site for
Stress test (*),Stress test (amd_cfi)andUpgrade check (*): 35 job instances across five workflows.Validated with these exact flags including
--privileged, against a control with the cap removed andnothing else changed; both arms are below. No
ci/defs/change, sopraktika yamlleaves.github/workflows/unchanged.Known and unchanged:
max_memory_usage_for_userstays host-derived at 18.50 GiB, below the newceiling. The libFuzzer and vector-search containers are also uncapped, but I have no runner-loss
observation for either.
Memory envelope before and after, on the measured 61.65 GiB
*-mediumrunnermemory.maxreadsmax)gdb, clients, page tables)The reserve is 8 GiB because #116782 measured 4.6 GiB of host headroom left at failure, and 4.6 was
not enough. The server's ceiling therefore drops 12.98%, so stress runs meet
MEMORY_LIMIT_EXCEEDEDa little sooner, and an overshoot becomes an in-container kill: the job stillpublishes its result, logs and cores instead of losing the runner and publishing nothing, and an OOM
is already an allowed outcome there (
stress_job.py:441). Lowering the harness ratio instead wastried on the stateless jobs and reverted the same day (#110293, #110572); that is a different
mechanism, and it would bound only the server rather than
gdband the clients sharing this cgroup.Measured in the
clickhouse/stress-testimage with the job's own flags, differing only in--memory. With the cap:memory.maxreads the exact byte value passed, a plain 12 GiB allocationis SIGKILLed by the kernel, and a query the server refuses reports a
maximum:scaled from the caprather than from the host. Control, cap removed and nothing else changed:
memory.maxreadsmax,the same 12 GiB allocation completes, and the same query passes a host-derived ceiling.
Workflow [PR]
Sync PR [sync-upstream/pr/118057]
Version info
26.9.1.1363(included in26.9and later)