Repository navigation
Reserve host memory for the CI runner agent in the fuzzer jobs - #116782
alexey-milovidov merged 1 commit into
Conversation
The fuzzer jobs give one unbounded container a whole shared runner: get_run_command passes no --memory, and inside the container only max_server_memory_usage_to_ram_ratio is set while max_server_memory_usage stays 0, so the server sizes itself from the host (46.33 of 61.78 GiB). On PR ClickHouse#116666 the container reached "current RSS: 57.14 GiB" against "maximum: 46.18 GiB" while every query was refused with Code 241. That RSS is the container cgroup's anon, so it charges clickhouse-client and two gdb processes as well, and the server's own ratio cannot bound it. About 4.6 GiB was left for the runner agent; it lost communication, the Run step concluded cancelled, and since upload happens after Run the job published nothing. CI DB has 0 rows for AST fuzzer (amd_debug, targeted) at that commit, while the twin old_compatibility arm fuzzed the same two query files against the same diff at the same commit and passed. --memory is a kernel bound on the whole container, so the reserve holds whatever the server, gdb and the client do. The launcher stays outside the container, so an in-container kill leaves it alive to publish a result. The derived form follows ci/defs/job_configs.py and adapts to both runner classes; 8 GiB rather than that file's 2 GiB because the agent lost communication with 4.64 GiB still available, and the runner's at-rest footprint is already about 2.4 GiB. max_server_memory_usage_to_ram_ratio is deliberately unchanged and becomes an inner margin: the container cap is 53.78 GiB and the server ceiling 40.33 instead of 46.33 GiB. Lowering that ratio was tried and reverted before (ClickHouse#110293, reverted by ClickHouse#110572) for flooding unrelated tests with MEMORY_LIMIT_EXCEEDED. Validated locally: the flag binds a container carrying this job's exact flags including --privileged, and ClickHouse then reports the container size rather than the host's (8.00, 4.00 and 16.00 GiB as the cap varies, 755.49 GiB with no flag, and 8.00 down to 3.00 GiB through the cgroups v1 code path); 2 GiB of anon in a 512 MiB container of this shape is killed by the kernel and succeeds uncapped; all 10 fuzzer job digests change while 164 other PR jobs do not; and pytest ci/tests/ has identical pass/fail sets with and without the change. Related: ClickHouse#111892 Co-Authored-By: Claude Opus 5 <[email protected]>
Internal second-model review (click to expand)An independent model reviewed this diff cold over three rounds. Everything it raised is below with ❌ Fixed
💡 Noted, not blocking
Session id: cron:clickhouse-review-slot-8:20260827-184502 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-7:20260827-174900 |
|
Workflow [PR], commit [2931d8b] Summary: ✅ AI ReviewSummaryThis PR adds a host-side Findings
Final Verdict
|
|
cc @maxknv, could you review this? The fuzzer jobs pass no |
| # For sysctl | ||
| "--privileged " | ||
| "--network=host " | ||
| f"--memory={Utils.physical_memory() - RUNNER_MEMORY_RESERVE} " |
There was a problem hiding this comment.
This adds a memcg cap to the fuzzer container, but the post-run classifier still treats any fuzzer_exit_code == 137 with a live server as success (ci/jobs/ast_fuzzer_job.py:451-458). If the kernel kills clickhouse-client or the timeout wrapper instead of clickhouse-server, run-fuzzer.sh writes server_died=0 / fuzzer_exit_code=137 to status.tsv (ci/jobs/scripts/fuzzer/run-fuzzer.sh:315-428), and we now return OK with no artifacts even though the fuzz run was cut short by the new cap. That means this change can trade the current "runner lost communication" failure for a false green that silently loses fuzz coverage.
Can we disambiguate "budget expired and timeout had to SIGKILL" from "memcg OOM killed the client" before treating 137 as benign here?
There was a problem hiding this comment.
Verified, and the mapping is as you describe: ast_fuzzer_job.py:451-458 returns OK for fuzzer_exit_code 137 with a live server. That arm predates this PR and is deliberate, its own comment reading "normal exit with timeout or OOM kill", and run-fuzzer.sh:274 produces it through timeout --signal TERM --kill-after=5m.
What I disagree with is that the cap makes that the likely outcome, because a memcg OOM kills the largest task in the cgroup rather than the one that allocates. Measured in the clickhouse/fuzzer image with this job's flags (--privileged --memory=512m): a 400 MiB process was SIGKILLed while a second one bounded at 140 MiB, whose allocation is what crossed the cap, exited 0. The fuzzer client is bounded at 1 GB by --max_memory_usage_in_client (run-fuzzer.sh:275) against a 53.78 GiB container cap, so the server is the victim, and a dead server sets server_died=1 (run-fuzzer.sh:410) and takes the named-failure branch instead of the 137 arm.
The gap is inside that branch: its dmesg grep only matches global-OOM text. A memcg kill prints Memory cgroup out of memory: Killed process and oom-kill:constraint=CONSTRAINT_MEMCG, and the three needles at ast_fuzzer_job.py:521 match 0 lines of captured kernel output while those two match all of it. #116359 already rewrites that exact grep, so the memcg needle belongs there rather than in a second hunk here. The client-killed variant stays disclosed in the description.
| # For sysctl | ||
| "--privileged " | ||
| "--network=host " | ||
| f"--memory={Utils.physical_memory() - RUNNER_MEMORY_RESERVE} " |
There was a problem hiding this comment.
This PR's new contract lives entirely in the rendered docker run string, but there is no committed ci/tests guard that asserts get_run_command actually emits this --memory= cap. The existing test_ast_fuzzer_memory_limit.py coverage is all about 241 classification, so a later refactor that drops or miscomputes this flag would keep the committed suite green while reintroducing the lost-runner failure this patch is fixing.
Please add a focused unit or source-level test that stubs Utils.physical_memory() and checks the generated command for both buzzhouse=False and buzzhouse=True.
There was a problem hiding this comment.
The risk is real, nothing committed asserts the flag.
I am not adding it, on the in-tree rulebook. .claude/CLAUDE.md: "When you want to test changes in the CI scripts, you can write and run a throwaway test, but you don't need to commit it to the repository, because we don't have automated CI tests" (added 2026-08-13 in ee29730735613f4). The same author has PR 114675 merged, removing the CI-script unit tests, and PR 115650 "Remove ci/tests (attempt 2)" open. test_ast_fuzzer_memory_limit.py is a file I added in July, before that line landed, so I would not cite it as precedent for adding more arms beside it.
What I ran instead: the command get_run_command renders was executed in both arms, and ClickHouse inside the container reads 755.49 GiB with no flag against 747.49 GiB with it, exactly physical minus the 8 GiB reserve; all 10 fuzzer job digests change while 164 other jobs do not. CI Tests passes on this change.
If a maintainer wants a committed guard here anyway, I will add it.
CI finish ledger - 2931d8bCI is fully finished at this commit. One check failed, and it has an owner.
Everything else at this commit is green. Across all 7 workflow runs at this head, that one fuzzer leg is the only job that is neither Session id: cron:our-pr-ci-monitor:20260827-213000 |
f311601
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Bound the AST fuzzer and BuzzHouse containers so a fuzz run cannot exhaust the CI runner host.
Description
Related: #111892
Related: #115915
Related: #116666
AST fuzzer (amd_debug, targeted)on #116666 reportedfailurehaving published nothing: theRunstep wascancelledafter the runner agent lost communication, so CI DB has 0 rows forit. The twin arm and four more passed on it.
Report,
job log.
Nothing bounds the job's share of the host:
get_run_commandpasses no--memory, and inside thecontainer
max_server_memory_usagestays0with only the 0.75 ratio set, so the server sizeditself at 46.33 of the runner's 61.78 GiB. The container then reached
current RSS: 57.14 GiBagainst
maximum: 46.18 GiBwith every query refused. That RSS is the container cgroup's anon andcharges the client and two
gdbprocesses too, so the server's ratio cannot bound it; 4.6 GiB wasleft for the agent.
I add
--memory=Utils.physical_memory() - RUNNER_MEMORY_RESERVEto thatdocker run, in the shapeci/defs/job_configs.pyalready uses; 8 GiB because 4.6 was not enough. A kernel bound holdswhatever the server,
gdband the client do, and the launcher stays on the host, so anin-container kill still publishes a result.
The 0.75 ratio is unchanged and becomes the inner margin: on that runner the cap is 53.78 GiB and
the server's ceiling 40.33 instead of 46.33 GiB. Lowering that ratio on the stateless jobs was
tried and reverted the same day (#110293, #110572) for flooding master with
MEMORY_LIMIT_EXCEEDED, by a different mechanism (below).Validated with this job's exact flags including
--privileged: the cap binds and ClickHousereports the container size. All 10 fuzzer job digests change; 164 others do not.
Known and unchanged: a cap trip that kills
clickhouse-clientinstead of the server is stillreported
OKwith no artifacts; the 10.81 GiB overshoot is one sample; the stress and libFuzzerjobs have their own uncapped containers, untouched here.
Memory envelope before and after, on a 61.78 GiB
*-mediumrunnergdb, shell)The overshoot on #116666 was 10.81 GiB, so a run of that shape keeps ~2.6 GiB of container slack. A
larger overshoot becomes an in-container OOM kill, which the job reports, instead of a lost runner,
which it cannot.
Fuzzed queries therefore meet
MEMORY_LIMIT_EXCEEDEDsooner. Three existing paths already absorbthat: the client clears a server-side 241 and keeps fuzzing (
FuzzLoop.cpp), the post-fuzz livenessprobe treats 241 as alive-and-busy (
run-fuzzer.sh), and a terminal server-survived 241 is reportedOK(ast_fuzzer_job.py). The reverted stateless change is not the same mechanism: the comment atci/jobs/functional_tests.py:909-927describes that flood as the aggregate RSS of dozens ofconcurrent
clickhouse-clientprocesses, whereas the fuzzer drives one client at a time(
run-fuzzer.sh:274) under amax_memory_usageof 10G from its own profile.The server sees the cap because these runners are cgroups v1 and the reader is scoped to the
container, not to the controller root: a retained fuzzer server log on the same runner class
(#111394) shows
Will create cgroup reader from '/sys/fs/cgroup/memory' (cgroups version: v1)andthen
resident: 156.19 MiBfrom that same reader at server startup, which the controller root couldnot report while the runner agent alone holds ~2.4 GiB.
--memoryis enforced by the kernel eitherway, so the 8 GiB reserve does not depend on this.
Workflow [PR]
Sync PR [sync-upstream/pr/116782]
Workflow [PR]
Sync PR [sync-upstream/pr/116782]
Version info
26.9.1.610(included in26.9and later)