Repository navigation
Fix distributed-plan sanitizer OOM: re-apply 0.7 memory ratio + cut concurrency - #110574
Conversation
…oncurrency Re-applies the sanitizer `max_server_memory_usage_to_ram_ratio` of 0.7 from #110293 (reverted in #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. #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: #108689 Related: #110293 Related: #110572 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Workflow [PR], commit [229d13b] Summary: ✅ AI ReviewSummaryThis PR re-applies the tighter sanitizer server memory cap, lowers concurrency for the Missing context / blind spots
Final Verdict
|
Address review from clickhouse-gh[bot]: prepare_stateful_data's is_sanitizer check (which lowers MAX_INSERT_THREADS from 16 to 4) only fired for the bugfix-validation path, since the normal (non-bugfix) call always passed build_type=None. Widening the 0.7 memory ratio to every sanitizer stateless run (this branch) means the normal path's setup-time INSERTs (25G/30G max_memory_usage, 16 insert threads) now run under the same tight cap without the reduced thread count, risking MEMORY_LIMIT_EXCEEDED during setup on the heaviest configs. args.options already carries the sanitizer name in the exact format is_sanitizer expects (e.g. "amd_asan_ubsan, distributed plan, parallel"), so pass it through for the normal path instead of None. Also cut the distributed-plan sanitizer parallel job's concurrency from 0.35 to 0.3 * CPU: this PR's own CI run at 0.35 still hit one Code 241 (RSS 43.01 GiB against the 41.84 GiB cap, ~3% over), so 0.35 left too little safety margin.
The non-flaky-check path passed `nproc` straight through as `--jobs`, so a low multiplier (e.g. the new `0.3 * CPU` for the sanitizer `distributed plan` parallel job) could floor to `0` on 2- or 3-core hosts. `clickhouse-test` divides by `jobs` in its parallel path, so `--jobs 0` would fail before any test runs. Clamp with the same `max(1, ...)` pattern already used for the flaky-check path.
`--options BugfixValidation` carries no build type, so the guard derived from `args.options` never applied the 0.7 `max_server_memory_usage_to_ram_ratio` cap there, even though the job launches the `*_asan_ubsan` master-HEAD binary first and later swaps to `tsan`/`msan` binaries. Derive the cap from the binary actually being launched (`build_types[0]`), and re-derive it in the validation loop on every binary swap: sanitizer builds rewrite the 0.7 override, the debug build removes it so the server default applies (the config tree is not reinstalled on a swap, so the previous build type's override would otherwise persist). Co-Authored-By: Claude Fable 5 <[email protected]>
The fresh run on `fd039f01c51` still hit two `MEMORY_LIMIT_EXCEEDED` (Code 241) failures in `Stateless tests (amd_asan_ubsan, distributed plan, parallel)` - `03742_nested_loop_join_long` and `03634_autopr_output_bytes_estimation` - with peak server RSS right on the `max_server_memory_usage_to_ram_ratio` cap (41.90 GiB and 41.84 GiB against a 41.84 GiB cap). At `0.3 * cpu_count` the runner (32-vCPU `c7i.8xlarge`) uses 9 parallel workers, which lands the aggregate RSS of co-scheduled `--distributed-plan` queries exactly on the cap, so the `OvercommitTracker` still rejects an occasional query. Each dropped worker sheds ~0.55 GiB of peak RSS (observed across the 0.35 -> 0.3 step), so cutting to `0.25 * cpu_count` (8 workers) leaves ~0.5 GiB of headroom below the cap instead of grazing it. The job ran in ~2h25m at 9 workers, so the ~11% throughput loss stays comfortably inside the 3h `timeout`. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110574&sha=fd039f01c511f2fbeb5f5cf6b5b8242e87318579&name_0=PR&name_1=Stateless%20tests%20%28amd_asan_ubsan%2C%20distributed%20plan%2C%20parallel%29 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
At 8 workers (`0.25 * cpu_count`) the fresh CI run brought the *sustained* peak server RSS just under the `0.7`-ratio cap (41.76 GiB vs 41.84 GiB), but `03742_nested_loop_join_long` was still rejected with `MEMORY_LIMIT_EXCEEDED` (Code 241) on a transient spike: a 512 MiB allocation while the shared server was already at 41.76 GiB, i.e. right on the cap. The victim is whichever query happens to ask for memory at the aggregate peak (the failing query itself only wanted 3.19 GiB), not a uniquely heavy test, so the only robust cure is to lower the baseline further. Cut `nproc` `0.25 -> 0.22 * cpu_count` (8 -> 7 workers on the 32-vCPU runner). The job's total wall-clock was ~2h36m at 8 workers, so the ~14% throughput loss from one fewer worker (~2h57m) needs a bit more headroom; raise the job `timeout` `3h -> 3.5h` to keep a comfortable margin. Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110574&sha=7c5f9fd36a06f522dccff6cabb2cbefe6473ab8e&name_0=PR&name_1=Stateless%20tests%20%28amd_asan_ubsan%2C%20distributed%20plan%2C%20parallel%29 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Address review: `DBReplicated` mode copies the installed main config tree into `/etc/clickhouse-server1` and `/etc/clickhouse-server2` (in `tests/config/install.sh`) and starts a server from each, and the copy happens before `set_memory_ratio` runs, so the two extra servers kept the default `0.9` `max_server_memory_usage_to_ram_ratio` and the host-OOM / `Server died` failure mode stayed reachable in sanitizer `DBReplicated` runs. Make `set_memory_ratio` / `reset_memory_ratio` operate on every installed server config tree instead of a single hardcoded path. Co-Authored-By: Claude Fable 5 <[email protected]>
The concurrency lever is exhausted: cutting workers 11 -> 9 -> 8 -> 7 moved the job's peak server RSS only 43.01 -> 41.90 -> 41.76 -> 41.71 GiB against the 41.84 GiB cap that the 0.7 ratio yields, and every run still grazed the cap with exactly one rejected query (Code 241 in 03742_nested_loop_join_long, a 512 MiB chunk while RSS sat just under the cap). The global memory check compares the server's OS RSS against the cap, and on an ASan server that RSS carries tens of GiB the memory tracker can neither see nor free by stopping queries (ASan shadow memory, quarantine, redzones, mmap-read file pages): the tracked amount at the failure was only 3.19 GiB. This overhead accumulates with the amount of work done, not with concurrency, so fewer workers cannot open a gap under the cap. Give this one job a 0.75 ratio (~44.8 GiB, ~3 GiB above the observed RSS equilibrium) instead of 0.7. The host-OOM invariant the cap protects (server cap + aggregate client RSS < RAM) still holds with >10 GiB to spare because the job's concurrency is already cut to 0.22 * CPU, which shrinks the ASan client footprint from ~17 GiB to ~3 GiB. Other sanitizer stateless runs keep 0.7. Failing run: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110574&sha=5c6474dffa6a61bca6a6f4b16703f3c82f06469d&name_0=PR&name_1=Stateless%20tests%20%28amd_asan_ubsan%2C%20distributed%20plan%2C%20parallel%29 Co-Authored-By: Claude Fable 5 <[email protected]>
|
If we reduce the number of parallel workers on the job by almost 2x, we should not increase the timeout; instead, split the job into 2 batches. A job that runs more than 2h is too long. 1h is the optimal test job duration. cc @alexey-milovidov |
|
The runner for the job is compute-optimized 32-core/64 GB - RunnerLabels.AMD_MEDIUM_CPU |
… cutting concurrency ClickHouse#110574 fixed the `MEMORY_LIMIT_EXCEEDED` (Code 241) flood in "Stateless tests (amd_asan_ubsan, distributed plan, parallel)" by cutting the job's test concurrency to `0.22 * CPU` (7 workers on the 32-vCPU runner), giving it a slightly higher `0.75` memory ratio, and raising its `timeout` to 3.5h. That kept the job green but made it much slower, and the tuning showed the concurrency lever barely moved peak server RSS anyway (43.01 -> 41.71 GiB across 11 -> 7 workers), because the ASan RSS baseline accumulates with work done, not concurrency. Fix it the right way instead: move the job from `AMD_MEDIUM_CPU` (32 vCPU, 64 GiB) to `AMD_LARGE` (same 32 vCPU, but 128 GiB RAM). With double the RAM the sanitizer `max_server_memory_usage_to_ram_ratio` cap of `0.7` sits well above the job's aggregate RSS at full concurrency, so the suite runs at the default `0.6 * CPU` workers and the default 2.5h timeout without overrunning the cap. - `ci/defs/job_configs.py`: `runs_on` `AMD_MEDIUM_CPU` -> `AMD_LARGE`; drop the 3.5h `timeout` override (restore the default). - `ci/jobs/functional_tests.py`: drop the distributed-plan `nproc` cut and the `is_distributed_plan` plumbing; drop the distributed-plan `0.75` memory-ratio special case (all sanitizer runs keep the `0.7` cap). The general sanitizer `0.7` memory cap and the all-config-tree `set_memory_ratio` / bugfix-validation handling from ClickHouse#110574 stay - those are the host-OOM ("Server died") fix, not the slowness cause. Related: ClickHouse#110574 Related: ClickHouse#108689 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Pick up the fleet-wide stateless-test host OOM mitigations (ClickHouse#110503, ClickHouse#110574) so CI on this branch produces real signal. Co-Authored-By: Claude Opus 4.8 <[email protected]>
… cutting concurrency ClickHouse#110574 fixed the `MEMORY_LIMIT_EXCEEDED` (Code 241) flood in "Stateless tests (amd_asan_ubsan, distributed plan, parallel)" by cutting the job's test concurrency to `0.22 * CPU` (7 workers on the 32-vCPU runner), giving it a slightly higher `0.75` memory ratio, and raising its `timeout` to 3.5h. That kept the job green but made it much slower, and the tuning showed the concurrency lever barely moved peak server RSS anyway (43.01 -> 41.71 GiB across 11 -> 7 workers), because the ASan RSS baseline accumulates with work done, not concurrency. Fix it the right way instead: move the job from `AMD_MEDIUM_CPU` (32 vCPU, 64 GiB) to `AMD_LARGE` (same 32 vCPU, but 128 GiB RAM). With double the RAM the sanitizer `max_server_memory_usage_to_ram_ratio` cap of `0.7` sits well above the job's aggregate RSS at full concurrency, so the suite runs at the default `0.6 * CPU` workers and the default 2.5h timeout without overrunning the cap. - `ci/defs/job_configs.py`: `runs_on` `AMD_MEDIUM_CPU` -> `AMD_LARGE`; drop the 3.5h `timeout` override (restore the default). - `ci/jobs/functional_tests.py`: drop the distributed-plan `nproc` cut and the `is_distributed_plan` plumbing; drop the distributed-plan `0.75` memory-ratio special case (all sanitizer runs keep the `0.7` cap). The general sanitizer `0.7` memory cap and the all-config-tree `set_memory_ratio` / bugfix-validation handling from ClickHouse#110574 stay - those are the host-OOM ("Server died") fix, not the slowness cause. Related: ClickHouse#110574 Related: ClickHouse#108689 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
03742_nested_loop_join_long is a residual MEMORY_LIMIT_EXCEEDED (Code 241) source on Stateless tests (amd_asan_ubsan, distributed plan, parallel). The failure is a server-wide OvercommitTracker rejection, not a per-query limit: the aggregate RSS of the heavy tests co-scheduled on one memory-capped sanitizer server (ratio cut in ClickHouse#110574) overruns the cap, so the tracker stops a query mid-JoiningTransform. This test is one of the heaviest contributors: its INNER events JOIN attributes fans a small left table (events, 34/33 rows per key) against a large right table (attributes, 800K/300K rows per key) into a 37.1M-row result that the direct-join path materializes as a single ~1.2 GiB chunk. ClickHouse#110574 already cut this shard's concurrency to its practical floor, and the direct join does not split its output by max_block_size, so reducing this test's own peak is the remaining lever. Shrink only the left-table row count, numbers(100) -> numbers(12) (4 rows per key). This cuts the INNER fan-out to 4.4M rows and the peak to ~400 MiB (~3x lower), while keeping everything the load test checks: the direct join algorithm, multi-match fan-out, the full 1.4M-row attributes right side, the Nullable key with NULL rows, and all four join strictnesses. The large events2 x attributes2 case is unchanged. Regenerate the reference; keep the long tag.
…lan-oom-concurrency Fix distributed-plan sanitizer OOM: re-apply 0.7 memory ratio + cut concurrency
Re-applies the sanitizer
max_server_memory_usage_to_ram_ratioof0.7from #110293 (reverted in #110572 because it caused a flood ofMEMORY_LIMIT_EXCEEDEDon master), and this time also lowers the test concurrency of the Stateless tests (amd_asan_ubsan, distributed plan, parallel) job so that the aggregate server memory of concurrent queries fits under the cap.Why the earlier attempt backfired. #110293 lowered the ratio to
0.7to stop the host OOM killer from reaping the server (Server died) on the heaviest sanitizer stateless configs, where ~17 GiB of concurrent ASanclickhouse-clientprocesses plus a0.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-planfans each query across local parallel replicas, multiplying per-query server memory. The aggregate then exceeded the lowered41.84 GiBcap and theOvercommitTrackerrejected queries across all co-scheduled tests with Code 241 (MEMORY_LIMIT_EXCEEDED) — hundreds of unrelated tests failed per run (6–213), isolated to this one variant (591/629 of its failures were Code 241; zero Code 241 in any other sanitizer stateless variant).Fix:
set_memory_ratio(0.7)for every sanitizer stateless run — covering all installed config trees, so the two extra servers ofDBReplicatedmode (/etc/clickhouse-server1/2) get the cap too.0.22 * CPU(below the0.4that azure already uses for the identical failure mode), so aggregate concurrent RSS stays under the cap. Gated to sanitizer builds; the healthy non-sanitizer (amd_debug) distributed-plan parallel job is left at the default concurrency. Tuned down in steps (0.35→0.3→0.25→0.22) against observed peak RSS.0.75. The tuning runs showed the peak RSS barely responds to concurrency (43.01 → 41.90 → 41.76 → 41.71 GiB for 11 → 9 → 8 → 7 workers against the 41.84 GiB cap, each run still grazing the cap with a single rejected query): the global memory check compares the server's OS RSS against the cap, and on an ASan server RSS carries tens of GiB the tracker can neither see nor free by stopping queries (ASan shadow memory, quarantine, redzones, mmap-read file pages — the tracked amount at the last failure was only 3.19 GiB). That overhead accumulates with work done, not concurrency, so the cap itself must give it room:0.75(~44.8 GiB) leaves ~3 GiB above the observed RSS equilibrium, while the host-OOM invariant (server cap + aggregate client RSS < RAM) still holds with >10 GiB to spare because the concurrency cut shrinks the ASan client footprint from ~17 GiB to ~3 GiB.timeoutfrom 2.5h to 3.5h so the reduced throughput (~2h44m at 7 workers) cannot turn a memory-red into a timeout-red.CI report of the disaster: play.clickhouse.com — master, Code 241 flood
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
Version info
26.7.1.1156(included in26.7and later)