Repository navigation
Fix Performance Comparison report-build host-OOM by disabling cgroup memory correction - #108804
Conversation
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-3:20260629-093600 |
|
cc @azat @alexey-milovidov — could you review? The perf report stage runs many |
| # Server settings (passed after `--`) for the report-building clickhouse-local | ||
| # invocations. They run inside the job's cgroup alongside the OS page cache left | ||
| # by reading the multi-GB datasets/logs. With memory_worker_use_cgroup=1 (the | ||
| # default) each process "corrects" its own memory tracker up to the cgroup-wide | ||
| # memory.current -- which includes that reclaimable page cache and any sibling | ||
| # clickhouse-local processes -- and can trip its total-memory hard limit with | ||
| # Code 241 MEMORY_LIMIT_EXCEEDED even though the query's own allocations are | ||
| # small. Disable cgroup correction so each report query is tracked against its | ||
| # own usage only. Keep in sync with CHPC_REPORT_LOCAL_SERVER_SETTINGS in | ||
| # ci/jobs/scripts/perf/compare.sh. |
There was a problem hiding this comment.
Here and below the comments should be compact, keep only essential things please
There was a problem hiding this comment.
Done in 74203e8 — trimmed both comment blocks (compare.sh and performance_tests.py) to the essential what + the keep-in-sync note; the full mechanism is in the commit message.
Please provide a link to CI report |
…correction The Performance Comparison report stage runs many clickhouse-local processes concurrently (GNU parallel in compare.sh, one per query for the randomization step) inside the job's single cgroup, next to the page cache from reading the multi-GB datasets and profile TSVs. clickhouse-local defaults to memory_worker_use_cgroup=1, so each process corrects its own total-memory tracker up to the cgroup-wide memory.current, which sums every sibling process plus reclaimable page cache, and trips its hard limit (Code 241 MEMORY_LIMIT_EXCEEDED in MergeSortingTransform/AggregatingTransform) even though each query's own allocations are small. This produced the recurring "Errors while Building the Report" job failure across many unrelated PRs and on master. Pass --memory_worker_use_cgroup=0 to every report-building clickhouse-local invocation so each report query is tracked against its own RSS via jemalloc/proc instead of the shared cgroup. The clickhouse-client calls to the measured left/right servers are left untouched. Per-query peak memory is unchanged, so aggregate memory stays well under the cap and parallel --memsuspend remains the aggregate backstop. Co-Authored-By: Claude Opus 4.8 <[email protected]>
bf6deb8 to
74203e8
Compare
CI report (this failure first surfaced as a finish-ledger line on PR #108790, The job's It is chronic and fleet-wide, not specific to one PR: in the last 7 days |
|
The link is wrong, the report.html does not have "Errors while Building the Report", and neither does job.log.zst |
|
Workflow [PR], commit [74203e8] Summary: ✅
AI ReviewSummaryThis PR disables Missing context / blind spots
Tests
Final VerdictStatus: Minimum required action: provide verifiable before/after evidence for the reported CI failure and this fix. I do not have a code-level inline finding from the current diff. |
|
You are right, and thanks for checking. That link no longer shows it: the Also, the Stable examples still on S3 (failure-only, not retried), PR #105066:
It is fleet-wide: 8 distinct unrelated PRs currently have accessible |
…ode 243 The report-building step of the Performance Comparison job runs many clickhouse-local processes (the eqmed.sql randomization step over each query, plus the aggregate report queries) with --memory_worker_use_cgroup=0. Without cgroup correction, getMostStrictAvailableSystemMemory() returns the full host RAM, so max_bytes_ratio_before_external_group_by (default 0.5) sets the external-aggregation spill threshold to ~0.5 * host RAM (~28 GiB on the arm-medium runner). The heaviest randomization queries cross that threshold and try to spill, reserving current_memory_usage bytes on report/tmp. But that disk is mostly full of the perf datasets and has only ~26 GiB free, so the reservation fails with Code: 243. DB::Exception: Not enough space on temporary disk, cannot reserve 29846883133 bytes on [_tmp_default: available: 26.57 GiB ...]: While executing AggregatingTransform. (NOT_ENOUGH_SPACE) That single stderr line lands in analyze/errors.log, is copied into report/errors.log, and report.py turns any non-empty report/errors.log into a "failure" with message "Errors while building the report." So the whole check goes red even though every query row succeeded and the perf verdict is computed. It recurs across many unrelated PRs and on master. These bookkeeping aggregations need well under 1 GiB of tracked memory (the failing job finishes with max_memory_usage=500M locally); the ~20 GiB RSS is jemalloc-retained pages and dataset page cache, not spillable state. The temp disk cannot hold a multi-GiB spill anyway, so spilling here is a misfiring safety valve. Pin the external group_by/sort thresholds (both the absolute and the ratio form) to 0 so these queries stay in RAM and never reserve temp disk, and add a per-query max_memory_usage cap so a pathological report query fails fast and in isolation instead of exhausting host RAM under GNU parallel's concurrency (parallel --memsuspend remains the aggregate backstop). The measured left/right servers are untouched; this changes only the post-processing local, so it cannot mask a real regression. Pass these as ordinary clickhouse-local query settings (BEFORE the -- separator), not after it. clickhouse-local only treats arguments after -- as config/server overrides (LocalServer::initialize loads them from config()), which is why --memory_worker_use_cgroup=0 (a server setting) is effective there. But max_bytes_before_external_* and max_memory_usage are user/query settings (src/Core/Settings.cpp), so after -- they are parsed into the application config and silently ignored (system.settings shows changed=0). Passed as normal options before --, they apply (changed=1) and actually close the Code 243 path. Split the settings accordingly in both compare.sh (the eqmed parallel step and the report/analyze/metrics heredoc queries) and the mirrored lists in performance_tests.py. Related: ClickHouse#108804
…ode 243 The Performance Comparison report-building step runs many clickhouse-local processes with --memory_worker_use_cgroup=0 (ClickHouse#108804). Without cgroup correction the external-aggregation spill threshold is ~0.5 * host RAM, so the heaviest report queries try to spill and reserve multi-GiB on the near-full report/tmp disk, failing with: Code: 243. DB::Exception: Not enough space on temporary disk ... (NOT_ENOUGH_SPACE) That line lands in errors.log and report.py turns any non-empty errors.log into a report failure, so the whole check goes red although every query row succeeded. It recurs across unrelated PRs and on master. Pin the external group_by/sort thresholds to 0 so these small aggregations stay in RAM (they need well under 1 GiB; the temp disk cannot hold a real spill anyway), and add a per-query max_memory_usage cap. Pass them as ordinary clickhouse-local query settings before the -- separator; after -- only config/server settings apply (which is why --memory_worker_use_cgroup=0 works there). The measured servers are untouched, so this cannot mask a regression. Related: ClickHouse#108804
…ode 243 The Performance Comparison report-building step runs many clickhouse-local processes with --memory_worker_use_cgroup=0 (ClickHouse#108804). Without cgroup correction the external-aggregation spill threshold is ~0.5 * host RAM, so the heaviest report queries try to spill and reserve multi-GiB on the near-full report/tmp disk, failing with: Code: 243. DB::Exception: Not enough space on temporary disk ... (NOT_ENOUGH_SPACE) That line lands in errors.log and report.py turns any non-empty errors.log into a report failure, so the whole check goes red although every query row succeeded. It recurs across unrelated PRs and on master. Pin the external group_by/sort thresholds to 0 so these small aggregations stay in RAM (they need well under 1 GiB; the temp disk cannot hold a real spill anyway), and add a per-query max_memory_usage cap. Pass them as ordinary clickhouse-local query settings before the -- separator; after -- only config/server settings apply (which is why --memory_worker_use_cgroup=0 works there). The measured servers are untouched, so this cannot mask a regression. Related: ClickHouse#108804
…ode 243 The Performance Comparison report-building step runs many clickhouse-local processes with --memory_worker_use_cgroup=0 (ClickHouse#108804). Without cgroup correction the external-aggregation spill threshold is ~0.5 * host RAM, so the heaviest randomization queries (eqmed.sql: input cross-joined with numbers(1,10000) + medianExactForEach state) try to spill and reserve ~28 GiB on the near-full report/tmp disk, failing with: Code: 243. DB::Exception: Not enough space on temporary disk ... (NOT_ENOUGH_SPACE) That line lands in errors.log and report.py turns any non-empty errors.log into a report failure, so the whole check goes red although every query row succeeded. It recurs across unrelated PRs and on master. The temp disk (~26 GiB free) cannot hold a spill of these queries, so spilling is not viable here; they must stay in RAM, which the runner has (host ~55 GiB, concurrency already bounded by parallel --memsuspend). Pin the external group_by/sort thresholds to 0 so the report aggregations never spill and never reserve temp disk. Pass them as ordinary clickhouse-local query settings before the -- separator; after -- only config/server settings apply (which is why --memory_worker_use_cgroup=0 works there). The measured servers are untouched, so this cannot mask a regression. Related: ClickHouse#108804
… data) The report-building clickhouse-local tries external aggregation for the heaviest eqmed.sql queries and fails with Code: 243 (NOT_ENOUGH_SPACE), because the near-full report/tmp disk cannot hold the reservation. That line lands in errors.log and report.py turns any non-empty errors.log into a report failure, so the whole check goes red although every query row succeeded. Disable external aggregation so these queries stay in RAM. With spilling off a single heavy job can peak ~30G, so also bound the parallel report jobs by host RAM to avoid Code: 241 (MEMORY_LIMIT_EXCEEDED). Also print report/errors.log to the job log so future failures are diagnosable without the results archive. The query settings must be passed before the -- separator; after -- only config/server settings apply (which is why --memory_worker_use_cgroup=0 works there). The measured servers are untouched, so this cannot mask a regression. Related: ClickHouse#108804
…report-cgroup-oom Fix Performance Comparison report-build host-OOM by disabling cgroup memory correction
No related open issue found.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Description
Fixes the recurring
Performance Comparison (..., master_head/release_base, N/6)job failure "Errors while Building the Report", which is a host-OOM at the report-assembly stage, not a perf regression:Seen across many unrelated PRs and on master (10+ distinct PRs in the last 7 days on
arm_releasealone).Root cause: the report stage runs many
clickhouse-localprocesses concurrently (GNUparallelincompare.sh::analyze_queries, one per query for the randomization step), all inside the job's single cgroup, alongside the OS page cache left by reading the multi-GB datasets and profile TSVs.clickhouse-localdefaults tomemory_worker_use_cgroup=1, so each process "corrects" its own total-memory tracker up to the cgroup-widememory.current-- which sums every siblingclickhouse-localplus reclaimable page cache. The tracker then trips its hard limit (Code 241) insideMergeSortingTransform/AggregatingTransformeven though each query's own allocations are small (the failing job's own request was well under 1 GiB; it was killed because the cgroup-wide RSS was 42.98 GiB).Fix: pass
--memory_worker_use_cgroup=0to every report-buildingclickhouse-localinvocation (the analyze/report/metrics queries incompare.shand thebuild_raw_query_metrics_tsv/build_flamegraph_upload_tsvcalls inperformance_tests.py). Each report query is then tracked against its own RSS via jemalloc/proc instead of the shared cgroup, so concurrent siblings and page cache no longer push it over the limit. This does not touch theclickhouse-clientcalls to the measured left/right servers -- those keep their normal memory limits. Per-query peak memory is unchanged (the queries are data-bound, not thread-bound), so aggregate anonymous memory stays well under the cap and the existingparallel --memsuspendremains the aggregate backstop.Reproduced locally with the snapshot binary by running several report queries concurrently inside a memory-capped cgroup (
systemd-run --scope -p MemoryMax=...): with the default (memory_worker_use_cgroup=1) the jobs fail with the exactCode 241 ... MEMORY_LIMIT_EXCEEDED ... While executing MergeSortingTransform/AggregatingTransformsignature; with--memory_worker_use_cgroup=0they all complete.Version info
26.7.1.254(included in26.7and later)