Repository navigation
Lower max_server_memory_usage_to_ram_ratio to 0.7 on sanitizer stateless runs - #110293
Conversation
…ess runs
Fixes recurring runner-wide OOM ("Server died" / "OOM in dmesg") on the
heaviest stateless configs (ASan/UBSan, parallel), where the server is
killed by the host OOM killer rather than by a per-query `max_memory_usage`
limit.
Root cause: on a sanitizer host the server is not the only large memory
consumer. The parallel runner keeps dozens of ASan-instrumented
`clickhouse-client` processes alive at once (~0.4 GiB each, ~17 GiB total on
a 60 GiB host). With the default `max_server_memory_usage_to_ram_ratio` of
0.9 the server alone is allowed to grow to ~0.9 of RAM, so together with the
clients it exhausts the host: a global OOM reaps `clickhouse-serv` at an RSS
well below the server's own logical limit, before any query can hit
`MEMORY_LIMIT_EXCEEDED`.
Example (master, sha f76b144, "Stateless tests (amd_asan_ubsan,
distributed plan, parallel)"): host 59.77 GiB, `max_server_memory_usage`
53.79 GiB (0.9), but the host OOM-killed the server at 42.67 GiB anon-rss
while ~17 GiB was held by concurrent ASan clients. ClickHouse's own memory
tracker never exceeded ~1.6 GiB during the whole run.
The reduced ratio was previously applied only in the flaky check (0.8, which
is sufficient there only because it runs a small test subset at reduced
concurrency). Apply it to every sanitizer run and lower it to 0.7 (41.8 GiB
cap on this host) so the clients' footprint still fits and the server kills a
runaway query gracefully instead of being OOM-killed by the host. 0.7 stays
comfortably above the largest legitimate single-query need (the ~25 GiB
stateful-load INSERT).
CI report:
https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=f76b144fcba22d6bedfb5ea7e5f1822456b549fb&name_0=MasterCI&name_1=Stateless%20tests%20%28amd_asan_ubsan%2C%20distributed%20plan%2C%20parallel%29
Related: #108689
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Workflow [PR], commit [a27a197] Summary: ✅ AI ReviewSummaryThis PR lowers Tests
Final Verdict
|
…less-oom-memory-ratio
The previous commit keyed the `max_server_memory_usage_to_ram_ratio` override off `args.options`, but in `bugfix_validation` mode `args.options` is only `BugfixValidation` - the sanitizer names never appear there. That mode downloads and swaps through several master-HEAD build-type binaries (`build_types`, e.g. `amd_asan_ubsan` / `amd_tsan` / `amd_msan`), most of them sanitizer builds, on the same memory-constrained runner, so it was left at the default `0.9` ratio and the same runner-wide OOM could still kill `clickhouse-server` instead of surfacing `MEMORY_LIMIT_EXCEEDED`. Key the ratio off the actual `build_types` under test in bugfix-validation mode so those sanitizer binaries are covered too, making the override apply to every sanitizer run as the comment claims. Addresses the AI review finding on #110293 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The AI review pointed out that `DBReplicated` sanitizer runs still escaped the reduced `max_server_memory_usage_to_ram_ratio`: `tests/config/install.sh` clones `/etc/clickhouse-server` into `/etc/clickhouse-server1` and `/etc/clickhouse-server2` before `set_memory_ratio` runs, and `ClickHouseProc.start` later launches both extra replicas from those copied configs. So a supported job like `amd_asan_ubsan,DBReplicated` left two server processes at the default `0.9` ratio, which can reproduce the same runner-wide host OOM under an even heavier three-server footprint. Make `set_memory_ratio` write the override into every replica config dir (`/etc/clickhouse-server1`, `/etc/clickhouse-server2`) as well as the primary when `is_db_replicated` is set, so all three servers honor the cap. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…less-oom-memory-ratio
|
#110293 lowered
The failing queries are heavy but legitimate (TPC-DS/TPC-H, |
|
Thanks, reverted. |
…oncurrency Re-applies the sanitizer `max_server_memory_usage_to_ram_ratio` of 0.7 from ClickHouse#110293 (reverted in ClickHouse#110572 because it caused a flood of `MEMORY_LIMIT_EXCEEDED` in the "Stateless tests (amd_asan_ubsan, distributed plan, parallel)" job on master), and this time also lowers the test concurrency for that job so the *aggregate* server memory of concurrent queries fits under the cap. ClickHouse#110293 lowered the ratio to 0.7 to stop the host OOM killer from reaping the server ("Server died") on the heaviest sanitizer stateless configs, where ~17 GiB of concurrent ASan `clickhouse-client` processes plus a 0.9-of-RAM server exceed the 60 GiB host. That reasoning only accounted for the largest single query (~25 GiB), but in the parallel runner dozens of test queries share one server, so the server memory tracker sees the aggregate, and `--distributed-plan` fans each query across local parallel replicas, multiplying per-query server memory. The aggregate then exceeds the lowered 41.84 GiB cap and the `OvercommitTracker` rejects queries across all co-scheduled tests (Code 241, `MEMORY_LIMIT_EXCEEDED`), so hundreds of unrelated tests failed on master with 6-213 failures per run. Fix: - Re-apply `set_memory_ratio(0.7)` for every sanitizer stateless run. - Cut the parallel distributed-plan sanitizer job's concurrency to 0.35 * CPU (below the 0.4 that azure already uses for the identical failure mode), so the aggregate concurrent RSS stays under the cap. The reduction is gated to sanitizer builds, since only they carry the 0.7 cap; the healthy non-sanitizer (amd_debug) distributed-plan parallel job is left at the default concurrency. - Raise that job's timeout from 2.5h to 3h so the reduced throughput (the job runs ~80 min at 0.6 * CPU) cannot turn a memory-red into a timeout-red. CI report of the disaster (master, Code 241 flood): https://play.clickhouse.com/play?user=play&run=1&color_modes=%7B%22ppm%22%3A%22none%22%2C%22test_name%22%3A%22categorical%22%7D&tab=Failed%20checks#U0VMRUNUIGNoZWNrX3N0YXJ0X3RpbWUsIGNoZWNrX25hbWUsIHRlc3RfbmFtZSwgcmVwb3J0X3VybApGUk9NIGNoZWNrcwpXSEVSRSAxCiAgICBBTkQgY2hlY2tfc3RhcnRfdGltZSA+PSBub3coKSAtIElOVEVSVkFMIDI0IEhPVVIKICAgIEFORCAoaGVhZF9yZWYgPSAnbWFzdGVyJyBBTkQgc3RhcnRzV2l0aChoZWFkX3JlcG8sICdDbGlja0hvdXNlLycpKQogICAgQU5EIHRlc3Rfc3RhdHVzICE9ICdTS0lQUEVEJwogICAgQU5EICh0ZXN0X3N0YXR1cyBMSUtFICdGJScgT1IgdGVzdF9zdGF0dXMgTElLRSAnRSUnKQogICAgQU5EIGNoZWNrX3N0YXR1cyAhPSAnc3VjY2VzcycKT1JERVIgQlkgY2hlY2tfc3RhcnRfdGltZSBERVNDLCBjaGVja19uYW1lLCB0ZXN0X25hbWU7 Related: ClickHouse#108689 Related: ClickHouse#110293 Related: ClickHouse#110572 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
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]>
The previous commit keyed the `max_server_memory_usage_to_ram_ratio` override off `args.options`, but in `bugfix_validation` mode `args.options` is only `BugfixValidation` - the sanitizer names never appear there. That mode downloads and swaps through several master-HEAD build-type binaries (`build_types`, e.g. `amd_asan_ubsan` / `amd_tsan` / `amd_msan`), most of them sanitizer builds, on the same memory-constrained runner, so it was left at the default `0.9` ratio and the same runner-wide OOM could still kill `clickhouse-server` instead of surfacing `MEMORY_LIMIT_EXCEEDED`. Key the ratio off the actual `build_types` under test in bugfix-validation mode so those sanitizer binaries are covered too, making the override apply to every sanitizer run as the comment claims. Addresses the AI review finding on ClickHouse#110293 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…ateless-oom-memory-ratio Lower max_server_memory_usage_to_ram_ratio to 0.7 on sanitizer stateless runs
…oncurrency Re-applies the sanitizer `max_server_memory_usage_to_ram_ratio` of 0.7 from ClickHouse#110293 (reverted in ClickHouse#110572 because it caused a flood of `MEMORY_LIMIT_EXCEEDED` in the "Stateless tests (amd_asan_ubsan, distributed plan, parallel)" job on master), and this time also lowers the test concurrency for that job so the *aggregate* server memory of concurrent queries fits under the cap. ClickHouse#110293 lowered the ratio to 0.7 to stop the host OOM killer from reaping the server ("Server died") on the heaviest sanitizer stateless configs, where ~17 GiB of concurrent ASan `clickhouse-client` processes plus a 0.9-of-RAM server exceed the 60 GiB host. That reasoning only accounted for the largest single query (~25 GiB), but in the parallel runner dozens of test queries share one server, so the server memory tracker sees the aggregate, and `--distributed-plan` fans each query across local parallel replicas, multiplying per-query server memory. The aggregate then exceeds the lowered 41.84 GiB cap and the `OvercommitTracker` rejects queries across all co-scheduled tests (Code 241, `MEMORY_LIMIT_EXCEEDED`), so hundreds of unrelated tests failed on master with 6-213 failures per run. Fix: - Re-apply `set_memory_ratio(0.7)` for every sanitizer stateless run. - Cut the parallel distributed-plan sanitizer job's concurrency to 0.35 * CPU (below the 0.4 that azure already uses for the identical failure mode), so the aggregate concurrent RSS stays under the cap. The reduction is gated to sanitizer builds, since only they carry the 0.7 cap; the healthy non-sanitizer (amd_debug) distributed-plan parallel job is left at the default concurrency. - Raise that job's timeout from 2.5h to 3h so the reduced throughput (the job runs ~80 min at 0.6 * CPU) cannot turn a memory-red into a timeout-red. CI report of the disaster (master, Code 241 flood): https://play.clickhouse.com/play?user=play&run=1&color_modes=%7B%22ppm%22%3A%22none%22%2C%22test_name%22%3A%22categorical%22%7D&tab=Failed%20checks#U0VMRUNUIGNoZWNrX3N0YXJ0X3RpbWUsIGNoZWNrX25hbWUsIHRlc3RfbmFtZSwgcmVwb3J0X3VybApGUk9NIGNoZWNrcwpXSEVSRSAxCiAgICBBTkQgY2hlY2tfc3RhcnRfdGltZSA+PSBub3coKSAtIElOVEVSVkFMIDI0IEhPVVIKICAgIEFORCAoaGVhZF9yZWYgPSAnbWFzdGVyJyBBTkQgc3RhcnRzV2l0aChoZWFkX3JlcG8sICdDbGlja0hvdXNlLycpKQogICAgQU5EIHRlc3Rfc3RhdHVzICE9ICdTS0lQUEVEJwogICAgQU5EICh0ZXN0X3N0YXR1cyBMSUtFICdGJScgT1IgdGVzdF9zdGF0dXMgTElLRSAnRSUnKQogICAgQU5EIGNoZWNrX3N0YXR1cyAhPSAnc3VjY2VzcycKT1JERVIgQlkgY2hlY2tfc3RhcnRfdGltZSBERVNDLCBjaGVja19uYW1lLCB0ZXN0X25hbWU7 Related: ClickHouse#108689 Related: ClickHouse#110293 Related: ClickHouse#110572 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Fixes recurring runner-wide OOM (
Server died/OOM in dmesg) on the heaviest stateless configs (ASan/UBSan, parallel), where theclickhouse-serverprocess is killed by the host OOM killer rather than by a per-querymax_memory_usagelimit or a per-test bug.Root cause. On a sanitizer host the server is not the only large memory consumer. The parallel runner keeps dozens of ASan-instrumented
clickhouse-clientprocesses alive at once (~0.4 GiB each, ~17 GiB in total on a 60 GiB host). With the defaultmax_server_memory_usage_to_ram_ratioof0.9the server alone is allowed to grow to ~0.9 of RAM, so together with the clients it exhausts the host: a global OOM reapsclickhouse-servat an RSS well below the server's own logical limit, before any query can hitMEMORY_LIMIT_EXCEEDED.Evidence (master, sha
f76b144fcba2,Stateless tests (amd_asan_ubsan, distributed plan, parallel)):max_server_memory_usageset to 53.79 GiB (0.9 ratio).global_oom, constraint=CONSTRAINT_NONE), while ~17 GiB was held by the concurrent ASanclickhouse-clientprocesses (dozens visible in thedmesgprocess table).query_log,trace_log,metric_log, server log) truncates 4-8 s before the fatal window — the runaway allocation starved logging. So the specific victim query is unattributable, consistent with the external-kill host-OOM class in Runner-wide OOM (OOM in dmesg / Server died) on Stateless test runners, especially arm_asan_ubsan, azure #108689.Fix. The reduced ratio was previously applied only in the flaky check (
0.8, sufficient there only because it runs a small test subset at reduced concurrency). Apply it to every sanitizer run and lower it to0.7(41.8 GiB cap on this host) so the clients' footprint still fits and the server kills a runaway query gracefully withMEMORY_LIMIT_EXCEEDEDinstead of being OOM-killed by the host.0.7stays comfortably above the largest legitimate single-query need (the ~25 GiB stateful-load INSERT).CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=f76b144fcba22d6bedfb5ea7e5f1822456b549fb&name_0=MasterCI&name_1=Stateless%20tests%20%28amd_asan_ubsan%2C%20distributed%20plan%2C%20parallel%29
Related: #108689
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Documentation entry for user-facing changes
🤖 Generated with Claude Code
Version info
26.7.1.968(included in26.7and later)