Repository navigation
CI: bound each docker buildx invocation in the Docker image jobs - #113869
Conversation
`Docker server image` and `Docker keeper image` wedged with no output for about five hours and then died on the praktika 18000s job cap, four times on 2026-08-05 across four unrelated PRs, producing no image and no usable log. The stall is inside `apt-get update` against the in-region Ubuntu mirror. apt cannot bound it. `Acquire::http::Timeout` is an inactivity timeout, not a wall-clock one: measured against a local mirror, one that never answers lets `apt-get update` return in 248s, but one trickling a byte per second was still running at a 700s cap, and `Acquire::Retries=5` does not change that. The failing jobs show the trickling shape, their throughput decaying to about 6 kB/s in the last logged fetches. Re-adding `Acquire::Retries` to the published Dockerfiles is also not an option: 7cb4072 deliberately removed it. The retry configured here could never run either. Both call sites already pass `retries` and `retry_errors`, but `Result.from_commands_run` never forwards a `timeout` to `Shell.run`, so a command that never returns is never retried. All four job logs contain zero `Retryable error` lines. Wrap both invocations in GNU `timeout` and let the existing retry machinery act on the expiry. An expiry is recognised on 124 via an echoed sentinel, and on the escalated 137 only when `timeout` logged its own KILL diagnostic, so an OOM or an external kill is not mistaken for one; this is the discrimination `clickhouse_proc.py` already makes with `_TIMEOUT_KILL_DIAG`, and `LC_ALL=C` pins that translated string. Both sentinels go to stderr, which is the only stream `Shell.run` matches against. A real build error still fails fast with its own status. The wrapper is a brace group rather than `bash -c`, because the buildx command already contains single-quoted arguments: the `bash -c` form returns rc 0 while silently truncating a space-bearing `--build-arg` at the space, so the exit code is not the oracle for it and the argv is pinned instead. A single per-invocation constant would not bound the job. `main()` loops over the os variants and tags, each running one build per architecture plus a push, so the invocation count is not fixed, and nine successful builds at 2700s exceed the cap on their own. Each invocation therefore gets what remains of the cap after a 3600s reserve, divided by the retry count, which bounds the job by construction for any variant count: the scheduled shape's worst case is 16334s against 18000s, and the envelope holds to four os variants at one tag. A passed deadline is clamped to 60s rather than 0, since `timeout 0` runs the command unbounded. The starting bound of 2700s is above the slowest healthy single attempt over 90 days (1819.1s; one job was green on a single 1748.1s attempt). Lowering `BUILDX_RETRIES` from 5 to 2 is what makes that arithmetic fit, and it applies to the registry and mirror signatures the constant already covered as well, since `Shell.run` takes one retry count for all of its retry tokens. At five attempts the largest bound that fits is 255s, seven times below the slowest healthy attempt, so five attempts would kill passing builds rather than wedged ones. `ci/tests/test_docker_buildx_timeout.py` pins what would otherwise fail silently: that arithmetic against `JobConfigs.docker_server.timeout` rather than a hardcoded cap, both call sites still passing `retries` and `retry_errors`, the sentinels arming a real retry, the argv surviving the wrapper, and a bare 137 not being read as an expiry. Two arms drive the shipped code rather than its source text, because a substring assertion cannot see either regression: one runs `build_and_push_image` and reads the bound back out of every command it produces, so reverting the call sites to a fixed bound is caught, and one drives `with_timeout` itself through `Shell.run`, so a non-positive kill delay is caught. A zeroed delay never escalates, which leaves a build that ignores SIGTERM running to completion and then retried on the 124 sentinel. The retry arms assert the attempt count through the real `Shell.run`, not membership in `BUILDX_RETRY_ERRORS`: that list is built from the sentinel constants, so a membership assertion stays true even for a token `timeout` never emits. Replacing the KILL diagnostic with such a string drops that arm from two attempts to one. The worst case walks `main()`'s own loop, which has no break and no `is_ok()` gate between variant/tag groups, so it allows a wedge in every group rather than one per job; the early returns inside `build_and_push_image` end only their own group. Each invocation gets all three fates `Shell.run` admits, not two: succeeding first try, wedging on every attempt, and expiring some number of times before a later attempt succeeds. The third is the expensive one, costing nearly as much as a wedge while leaving the rest of the group to run, and omitting it understates the scheduled shape by 1210s. It is exact by construction: group cost is a pure function of the elapsed time on entry and the per-invocation fates, so traces reaching the same elapsed are merged instead of enumerated. Restoring five retries takes the four-variant push shape to 23490s, and cutting the reserve to 600s takes the scheduled shape to 18972s; both fail. A separate arm pins the single tag both scheduled job commands request, since `--tag-type release` would build four tags and does not fit; that shape is not reachable from any scheduled job.
main() is the only production caller of build_and_push_image, and it was the only thing supplying the stopwatch and the job cap. Both parameters were optional, and buildx_timeout returns the fixed BUILDX_TIMEOUT whenever job_timeout is falsy, so dropping those two keyword arguments silently reverted every invocation to a fixed 2700s bound with the whole test suite green: the scheduled shape then prices at 50058s against the 18000s job cap, up from 16334s. Make both parameters required so that omission is a TypeError rather than a silent downgrade, and pin main()'s call site with an AST assertion, since a signature can be relaxed again. The existing arm that drives build_and_push_image supplies both arguments itself, so it pins the two inner call sites but structurally cannot see main(). The scope premise for that envelope asserted the textual presence of `--tag-type head` in the scheduled commands. argparse resolves a repeated option to its last occurrence, so appending `--tag-type release` left the assertion green while the job built four tags, a shape priced at 23948s. Resolve the commands through the shipped parse_args instead and assert the effective value. Co-Authored-By: Claude Opus 5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 9 gated rounds, 2 on the approach
Severity: ❌ blocker / Checked independently of the author's notes, before reading them: the budget arithmetic was Session id: cron:clickhouse-review-slot-11:20260807-175212 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-40:20260807-142000 |
|
cc @Felixoid @leshikus, could you review this? |
|
Workflow [PR], commit [88f5a3d] Summary: ✅ AI ReviewSummaryThis PR wraps the two Findings
Final VerdictChanges requested: the timeout wrapper looks reasonable, but the end-to-end “whole job stays inside the cap” guarantee is not proven by the current model. |
|
This has escalated sharply since the PR was opened, so it is worth re-stating the case with fresh data. A new occurrence today: The last output before five hours of silence is the same shape described above: Counting the 5 h job timeouts of
43 of the 53 occurrences are in the last four days, and master is now affected. Each one burns five hours of a runner and produces no image and no per-image result at all: the job writes a single empty CIDB row with I checked five of the recent wedges (#114262, #114596, #115074, #78927 and master Two things I verified independently while triaging that failure:
One interaction to decide before either lands, since both touch the same region of |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction. Compile time of recompiled translation units6 translation units recompiled, 4 s compile time in total, 6 of them have a recent master baseline. |
The AST guard collected only `kw.arg`, so it stayed green for `job_timeout=0` and for `sw=Utils.Stopwatch()`. Both restore the fixed 2700s bound while spelling the keywords: a falsy cap makes `buildx_timeout` return early, and a fresh stopwatch reports zero elapsed, so the deadline stops shrinking across invocations and the job-envelope guarantee disappears. Assert each value is the live `ast.Name` load instead. Measured against the shipped module: `job_timeout=0` and `sw=Utils.Stopwatch()` each redden this arm and left the whole suite green before this change; dropping both keywords still reddens it; annotating the call site without changing the bindings leaves all 22 arms green.
|
Thanks - agreed on folding it in here, and your stdout/stderr point matches what I measure. One correction before it lands: the expiry has two sentinels, not one.
So The envelope has room for the extra attempt. Worst case over every choice of which
and it is recoverable rather than merely bounded: when the in-region retries are exhausted Happy to fold it in here. I have not done so yet since #115726 is yours and still open - if Separately, I pushed 88f5a3d for the AI review's point on the |
| return max(reachable) | ||
|
|
||
|
|
||
| def test_the_whole_job_worst_case_fits_inside_the_jobs_own_cap(): |
There was a problem hiding this comment.
test_the_whole_job_worst_case_fits_inside_the_jobs_own_cap currently only models the build_and_push_image loop, but main() still does real work outside that loop: docker_login() on the push path, then test_docker_library() on the non-push path, and check_server_readme() on both paths. So this arm proves that the bounded buildx portion fits under the cap, not that the whole job does.
With the shipped helper, the build loop still leaves only about 2512 s of slack on PR jobs and 1666 s on push jobs, so an expensive tail phase can still hit the 18000 s Praktika timeout while this test stays green. Can we either include those extra phases in the envelope, or narrow the code/comments/tests to claim only that the buildx portion is bounded?
There was a problem hiding this comment.
Agreed, and narrowed rather than widened, in ddc3d64.
The arm is now test_the_build_loops_worst_case_fits_inside_the_jobs_own_cap and claims only
the loop. docker_login is not part of the tail, though: it runs before the loop, so the
stopwatch each deadline is derived from has already charged it. That leaves
test_docker_library and check_server_readme, and your 2512 s / 1666 s reproduce exactly.
Widening the envelope to include them would put an unbounded quantity inside an arm that
asserts a bound, so instead the slack is pinned as its own arm: it requires ten times the
slowest tail ever observed. Measured end to end, from the loop's last build to process exit
so the official-images clone and README.sh are inside the interval, over 60 whole jobs:
max 120.5 s, p50 67.5 s. The constant is 133 s, the larger figure from a 296-job sample, and
1330 s fits in 1666 s.
The two arms are not redundant: dropping the reserve to 2900 s leaves the envelope arm green
and reds the new one. Raising the constant to 134 stays green, to 167 reds.
Chasing this also turned up a real one next door, fixed in the same push. buildx_timeout
returned the unshrunk 2700 s bound when the cap was falsy, so zeroing both cap assignments in
main() left the whole suite green while the scheduled push shape modelled 50058 s against
18000 s. A missing cap is now refused, and the oracles that were counting textual prefixes
(retries=BUILDX_RETRIES + 1, retry_errors=BUILDX_RETRY_ERRORS[:-2], and a cap read from
an unrelated job's config) now compare the whole expression.
|
Following up on this PR's own retry machinery, because #115726 changed a quantity it depends on.
Walking
Two things make this hard to see:
I looked for a way to bring this back inside the cap and could not find one that holds. Every A caller-level budget check does not work either, and for a reason worth recording: That leaves three directions, and choosing between them is a call for whoever owns the mirror loop:
I am not proposing a patch for this, and I have not touched the mirror loop. Separately, the |
…the Docker image jobs
Backport #113869 to 26.7: CI: bound each docker buildx invocation in the Docker image jobs
…t divisor `BUILDX_RETRIES` was both the attempt cap for the retry ladder and the divisor that sizes each invocation's `timeout` bound, so one number budgeted two error classes whose per-attempt costs differ by three orders of magnitude. Raising the cap shrinks every invocation's bound, which is why it went from 5 to 2 when the `timeout` wrapper was added. At 2 attempts the ladder for a cheap failure spans a single 2s backoff, so one transient registry error consumes the whole budget in 2 seconds. In the report below the `ubuntu:22.04` manifest returned `500 Internal Server Error` twice inside those 2 seconds, having resolved fine four times in the preceding two minutes, and the job then failed holding 17854 of its 18000s unused. Give each class its own bound: BUILDX_RETRIES = 4 attempt cap BUILDX_EXPENSIVE_ATTEMPTS = 2 the only input to the buildx_timeout divisor BUILDX_RETRY_DEADLINE = 30 wall clock the ladder may span `buildx_timeout` now divides by `BUILDX_EXPENSIVE_ATTEMPTS`, which is 2 exactly where `BUILDX_RETRIES` was 2, so it returns the same values as before and the per-invocation bound does not move. The deadline is what holds the expensive class at 2 attempts. It is anchored at the first retryable failure, because an attempt may legitimately run for its whole bound before failing, and enforced twice: once before the sleep against the nominal delay, and once after it by re-reading the clock, since `time.sleep` may return late on a loaded runner. `on_retry` fires after the second check, so it never announces an attempt that is then cancelled. `retry_deadline` is additive on `Shell.run` and `Result.from_commands_run`. Left at `None` the eligibility test reduces to the `retry < retries - 1` the three failure paths already used, and the printed transcript is unchanged. The worst case for one invocation grows by exactly `BUILDX_RETRY_DEADLINE` - 2 = 28s, independently of the bound, so at most 15 * 28 = 420s per job against a `BUILDX_JOB_RESERVE` of 3600s. Related: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=117419&sha=b27939921a57ea5d41e0eb5df09d1acdc4c7266f&name_0=PR&name_1=Docker%20keeper%20image Related: ClickHouse#117419 Related: ClickHouse#113869 Co-Authored-By: Claude Opus 5 <[email protected]>
`BUILDX_RETRIES = 2` gives a `docker buildx` command in the Docker server and keeper image jobs one retry after a 2 s back-off, so a Docker Hub error that clears within seconds still fails the leg. On master 6b60183 (2026-09-30) the `head-distroless-arm64` keeper image built, and pushing it got `unexpected status from POST request to https://auth.docker.io/token: 500 Internal Server Error` twice, 3 s apart, so that image was not published: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=6b601838b5c7526a500254219a92542f852d5e55&name_0=MasterCI&name_1=Docker%20keeper%20image The count was 5 until ClickHouse#113869 lowered it to 2 while adding the per-invocation `timeout`. `buildx_timeout` divides the job's remaining budget by `BUILDX_RETRIES`, so with 5 an invocation whose every attempt expires still ends inside the job's reserve, and the per-attempt bound stays at 2700 s for the first 900 s of the job. A fast registry failure now gets 30 s of back-off (2, 4, 8, 16 s) instead of 2 s. Suggested in ClickHouse#121298 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…instead of retrying it The `timeout` sentinels `ERROR: docker buildx timed out` and `sending signal KILL to command` were appended to `BUILDX_RETRY_ERRORS` by ClickHouse#113869, so an attempt killed by `with_timeout` was retried on the same apt mirror. With `BUILDX_RETRIES = 5` a mirror that stalls every attempt would hold one leg for up to 5 x (2700 + 120) s + 30 s = 14130 s before `should_try_next_mirror` rebuilds against Canonical, whose attempts are then bounded by `buildx_timeout` at its 60 s floor. `should_try_next_mirror` already treats an expiry as a mirror failure (`is_buildx_timeout`), so a same-mirror retry is not needed: an expired attempt now matches no retry token, the invocation stops after one bound, and the unchanged mirror loop rebuilds against Canonical. A stalled mirror costs one bound (2820 s), and the Canonical rebuild keeps a per-attempt bound of 2316 s. Measured on all September 2026 job logs of `Docker keeper image` and `Docker server image` on master-based trees (20,140 jobs, 127,519 legs): 146 expiries, every one on the in-region mirror's `docker buildx build`, and in each the timeout sentinel was the only retry token that matched. 0 expiries on Canonical and 0 on the `imagetools create` push, the two places that lose their same-mirror retry. The Canonical rebuild succeeded for 152 of 152 legs (p50 242 s), faster than a same-mirror success after an expiry (p50 426 s). On master 1d6237c the keeper `head-distroless-arm64` build expired (12:11:13 to 12:56:13), its same-mirror retry failed with `Failed to fetch` at 12:57:07, and no rebuild against Canonical followed, so the check failed: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=1d6237ce14bd733c01641a182aa34e5938eaeff9&name_0=MasterCI&name_1=Docker%20keeper%20image Co-Authored-By: Claude Opus 5.5 <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
Docker server imageandDocker keeper imagewedged with no output for about five hours, then diedon the praktika 18000s job cap: four times on 2026-08-05 on four unrelated PRs, producing no image and
no usable log. No related open issue found. The stall is inside
apt-get update.apt cannot bound it:
Acquire::http::Timeoutis an inactivity timeout, not a wall-clock one.Measured locally, a mirror trickling a byte per second runs unbounded past a 700s cap, and
Acquire::Retries=5does not change that. The failing jobs show that shape.And the retry configured here could never run: both call sites pass
retriesandretry_errors, butResult.from_commands_runnever forwards atimeout, so a command that never returns is neverretried. All four logs show zero
Retryable errorlines.Both invocations are now wrapped in GNU
timeout, so an expiry is retried while a real build errorstill fails fast.
The bound starts at 2700s, above the slowest healthy single attempt over 90 days (1819.1s). A fixed
bound would not bound the job:
main()loops over os variants and tags, so the invocation count isnot fixed, and nine successful builds at 2700s exceed the cap alone. Each invocation instead gets what
remains of the cap after a 3600s reserve, divided by the retry count: the scheduled shape's worst case
is then 16334s against 18000s. That division is also why the retry count drops from 5 to 2: five
attempts fit only up to a 255s bound, seven times below the slowest healthy attempt, where two
attempts leave 881s above it. Being one count for all of
Shell.run's tokens, it applies to theregistry and mirror signatures too.
ci/tests/test_docker_buildx_timeout.pypins that arithmetic against the job's own cap, and thesentinels arming a real retry by attempt count rather than membership.
Validation (click to expand)
An expiry is recognised on 124, and on the escalated 137 only when
timeoutlogged its own KILLdiagnostic, so an OOM or an external kill is not mistaken for one: the same discrimination
clickhouse_proc.pymakes with_TIMEOUT_KILL_DIAG, withLC_ALL=Cpinning that translated string.Acquire::Retriesis deliberately not re-added to the published Dockerfiles, which would revert7cb4072. The
git cloneofdocker-library/official-imagesstays unbounded: not the aptlayer, never observed wedging.
Retry behaviour through the real
Shell.runat the shipped count of 2:exit 7kill -9)The last two are the discriminating controls. Replacing the KILL diagnostic with a string
timeoutnever prints drops the second arm to one attempt, proving the token is read rather than merely present
in a list. Quoting is pinned against an unwrapped baseline: the brace group reproduces every argument
byte-for-byte, while
bash -creturns rc=0 and truncates a--build-arg.The worst case walks
main()'s own loop, allowing a wedge in every variant/tag group rather than oneper job, since nothing breaks between groups; it is exact by construction, merging combinations that
reach the same elapsed. Restoring five retries, or cutting the reserve to 600s, reddens it at 18510s
and 18246s. One extra os variant stays green at 17180s, since a shrinking deadline absorbs it, while
thirty redden it. A separate arm pins the single tag both scheduled commands request: unreachable
--tag-type releasewould build four tags and not fit (23948s). Twenty-four of twenty-sixmutations redden a named arm; the other two are controls.
Workflow [PR]
Sync PR [sync-upstream/pr/113869]
Version info
26.8.1.1880(included in26.8and later)26.7.7.33