Skip to content

Cap the integration tests' /docker cgroup leaf at a ceiling, not at its share - #117411

Closed
alexey-milovidov wants to merge 1 commit into
masterfrom
fix-dind-docker-leaf-cap-too-tight
Closed

alexey-milovidov wants to merge 1 commit into
masterfrom
fix-dind-docker-leaf-cap-too-tight

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Aug 31, 2026 •

Copy link
Copy Markdown
Member

The integration tests run a nested Docker daemon whose cgroup is split into three capped leaves — /init (the harness), /dockerd (the daemons) and /docker (the nested test containers). /docker was the only leaf whose memory.max was its share of the job limit rather than a ceiling overlapping the other leaves, and that share does not hold what the leaf actually charges: besides the nested servers' anon memory it holds every byte they write, as page cache. The leaf therefore ran at its cap continuously, and the kernel OOM-killed a clickhouse server whenever reclaim could not keep up with writeback.

Measured on master, one day after the reporting for this condition became reliable: /docker reached the 40.78 GiB cap in nearly every run of every amd_asan_ubsan, db disk, old analyzer shard — including shards that passed — and the kill turned into Container memory budget exceeded (/docker) in 47.3% of the runs of shard 6/6, 26.9% of 5/6 and 17.0% of 2/6, plus a smaller number of amd_tsan and amd_llvm_coverage runs. In the reported run the leaf was killed three times at 40.78 GiB of 40.78 GiB while /dockerd sat at 18.36 GiB of 42.78 GiB and /init at 21.98 GiB of 56.78 GiB, and the job as a whole peaked at 47.14 GiB against its own 59.78 GiB limit — about 12 GiB the partition held back from the only leaf that had a use for it. The test_s3_plain_rewritable failure in the same report (Connection refused during OPTIMIZE TABLE test FINAL) is one of those killed servers.

/docker now gets CI_DIND_NESTED_LIMIT, the same ceiling /init has, while CI_DIND_NESTED_BUDGET stays its share and keeps sizing xdist concurrency, so the worker count is unchanged. Containment is unaffected — it comes from --cgroupns=private, and the job's own --memory still bounds the leaves together. The overlap with /init becomes mutual, where before only /init could borrow; what protects the harness is that the memory /docker borrows is page cache, which reclaim takes back before it touches anon, and a borrow that outgrows even that breaches the job's own cgroup, which job_cgroup_oom already reports.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=25dfbdb6c5dd3c0bd78c7134c14045ddb7647bcf&name_0=MasterCI&name_1=Integration%20tests%20%28amd_asan_ubsan%2C%20db%20disk%2C%20old%20analyzer%2C%206%2F6%29

Caused by: #112984

Changelog category (leave one):

  • CI Fix or improvement (changelog entry is not required)

Workflow [PR]
Sync PR [sync-upstream/pr/117411]

… its share

The nested test containers' leaf was the only one whose `memory.max` was its
share of the job limit rather than a ceiling overlapping the other leaves. That
share does not hold what the leaf actually charges: besides the nested servers'
anon memory it holds every byte they write, as page cache, so the leaf ran at
its cap continuously and the kernel OOM-killed a `clickhouse` server whenever
reclaim could not keep up with writeback.

Measured on master, one day after the reporting for this condition became
reliable: `/docker` reached the 40.78 GiB cap in nearly every run of every
`amd_asan_ubsan, db disk, old analyzer` shard - including shards that passed -
and the kill turned into `Container memory budget exceeded (/docker)` in 47.3%
of the runs of shard 6/6, 26.9% of 5/6 and 17.0% of 2/6, with a smaller number
of `amd_tsan` and `amd_llvm_coverage` runs. In the run below the leaf was
killed three times at 40.78 GiB of 40.78 GiB while `/dockerd` sat at 18.36 GiB
of 42.78 GiB and `/init` at 21.98 GiB of 56.78 GiB, and the whole job peaked at
47.14 GiB against its own 59.78 GiB limit: ~12 GiB the partition held back from
the only leaf that had a use for it.

So `/docker` now gets `CI_DIND_NESTED_LIMIT`, the ceiling `/init` has, while
`CI_DIND_NESTED_BUDGET` stays its share and keeps sizing xdist concurrency -
the worker count is unchanged. Containment is unaffected: it comes from
`--cgroupns=private`, and the job's own `--memory` still bounds the leaves
together. The overlap with `/init` becomes mutual, where before only `/init`
could borrow; what protects the harness is that the memory `/docker` borrows is
page cache, which reclaim takes back before it touches anon, and a borrow that
outgrows even that breaches the job's cgroup, which `job_cgroup_oom` reports.

Report:
https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=25dfbdb6c5dd3c0bd78c7134c14045ddb7647bcf&name_0=MasterCI&name_1=Integration%20tests%20%28amd_asan_ubsan%2C%20db%20disk%2C%20old%20analyzer%2C%206%2F6%29

Caused by: #112984
@clickhouse-gh

clickhouse-gh Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [7a54b0a]

Summary: ❌

job_name test_name status info comment
Bugfix validation (integration tests, amd64) ERROR
Bugfix validation (integration tests, aarch64) ERROR

AI Review

Summary

This PR splits the integration-tests nested Docker leaf into a worker-sizing CI_DIND_NESTED_BUDGET and a larger CI_DIND_NESTED_LIMIT ceiling, and the main wiring across job_configs.py, integration_test_job.py, and docker_in_docker.sh looks consistent. I did not find a blocker in the limit math or in the containment setup, but one diagnostics string still reports a /docker leaf OOM as a budget breach even though the actual memory.max is now the new limit.

Findings

💡 Nits

  • [ci/jobs/integration_test_job.py:133] The new budget/limit split is implemented here, but a /docker leaf OOM is still reported elsewhere as Container memory budget exceeded (/docker), and tests/integration/integration-tests-entrypoint.sh still describes CI_DIND_NESTED_BUDGET as the cgroup cap. That will point future triage at the wrong number once /docker is allowed to borrow above the worker-sizing share.
    Suggested fix: rename the /docker result text and adjacent commentary from budget to limit so the failure name matches the cgroup value that actually fired.
Final Verdict

✅ No blocking correctness issue found in the current diff. One diagnostics nit should be cleaned up so the new budget/limit split is described consistently.

LLVM Coverage Report

⚠️ No coverage measurement for commit 7a54b0a: no coverable C/C++ source files changed (contrib/ is excluded from coverage).

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Aug 31, 2026
40 GiB cap. Runs without the variable (local, or a job that sets no memory limit) keep
`CI_DIND_NESTED_BUDGET` is the share of the job limit that the cgroup parenting them owes the
other leaves nothing for, so deriving worker concurrency from it keeps scheduling and
containment on the same number. Its `memory.max` is `CI_DIND_NESTED_LIMIT`, a ceiling that

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that /docker is actually capped by CI_DIND_NESTED_LIMIT and CI_DIND_NESTED_BUDGET is only the worker-sizing share, the remaining diagnostics should stop describing a /docker leaf OOM as Container memory budget exceeded. DIND_LEAF_MEANINGS["docker"] and the comment in tests/integration/integration-tests-entrypoint.sh still send readers to the old number, so a run that hits the new ceiling will look like the 40 GiB budget was breached. Could you rename those to limit exceeded in the same change?

@Algunenano Algunenano self-assigned this Sep 1, 2026

@Algunenano Algunenano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAICT both this and #117412 address the same problem but #117412 it's simpler to understand and reason. I'll merge that one instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants