Skip to content

Fix the CI infrastructure auto-retry and rerun an infra job in a mixed run - #117282

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-retry-infra-failures-praktika-classification
Oct 11, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-retry-infra-failures-praktika-classification

Conversation

@groeneai

@groeneai groeneai commented Aug 31, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #109673 (the infra label this acts on)
Related: #113564 (candidate selector)
Related: #115569 (job-level heuristic)
Related: #116701 (duplicate runs at one commit)

Changelog category (leave one):

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

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

...

Description

The hourly auto-retry has never acted on the infra label #109673 added. A SQLLogic test job
killed at exit 125 by a host docker daemon death 67 minutes in is labelled correctly and
never retried (job log).
Five defects sit in one block of retry_infra_failures.yml:

  • a fork run carries no pull request number and the whole Praktika path is gated on one, so it
    is dead on every fork PR;
  • the job-name-to-filename normalization does not match praktika's, so most result URLs 403
    and the loop breaks on the first;
  • the failed-sub-result test compares lowercase statuses against praktika's uppercase ones, so
    it is always false; fixing only the URL would start rerunning real failures;
  • the label predicate matches a bare string only, missing the dict form set_label writes;
  • the only action is a whole-run rerun, correctly refused when the run also failed for real, so
    a mixed run was unrecoverable.

Classification now reads the run's result_pr.json once, the artifact Finish Workflow reads
for Mergeable Check, joining each entry to its job by ext.run_url. A mixed run with exactly
one infra job gets that job rerun, which also reruns its dependents and Finish Workflow; the
all-infra case still reruns whole.

Two side effects. Mergeable Check is a commit status and a rerun keeps the original commit, so
a run whose commit is no longer its pull request's head is now skipped; that narrows the existing
whole-run path too. A run sharing a commit with a concurrent run is left alone rather
than acted on from an artifact both wrote, which #116701 would fix at its source.

Untouched: the daemon death is a host condition (five distinct m8g.4xlarge hosts inside 36
minutes); two or more infra jobs in one run; master.yml runs; the legacy hlabels form.

Measurements and validation

Each defect, measured on live runs: .pull_requests is populated for 0 of 33 fork heads sampled
and for 7 of 7 same-repo heads; the normalization omits praktika's rstrip("_"), so 155 of
170 job names build a key that does not exist; praktika statuses are FAIL and ERROR, never
failure or error; 33b1f35c0ad fixed the dict-form label and 7d022e880fef reverted it
asking for a reapply; all three runs that have ever carried the label are mixed, so 3 of 3 uses
of the label were unrecoverable.

Validated over the 16 real (PR, commit) pairs that produced a SQLLogic test job-level failure
in 30 days. The step body was extracted from the YAML and driven over them with the rerun call
stubbed, beside the same harness running master's step.

step reruns what fired
master 1 whole-run rerun of run 32038224339, whose pull request is now closed at a different commit
this change 1 per-job rerun of SQLLogic test in run 33331951492, a mixed run still at its pull request's head
this change, head-commit guard neutralised 3 the two above plus SQLLogic test of #116805's run, which the guard skips because that PR has moved on

Two of the 16 runs share their commit with a concurrent run, and their result_pr.json does
carry entries stamped by both, so the per-job join is what keeps them from being acted on. Only
3 of the generated workflow's 170 jobs lack the pipeline_status guard, so a per-job rerun
re-runs at most one job that could have passed.

The three open pull requests above merge cleanly with this change.


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

Version info

  • Merged into: 26.10.1.2095-master (included in 26.10 and later)

@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-ci-own-pr PR origin: CI on a groeneai PR exposed a separate defect labels Aug 31, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex) over 3 rounds, beside an
independent cold read of the diff in each round. Two fix rounds were bounced back before
publication.

# Sev Finding Verdict Evidence / action
1 ⚠️ The per-job path ignores the job-level heuristic's per-job verdicts, so a run whose only infrastructure evidence is a fast Run failure takes no action (.github/workflows/retry_infra_failures.yml:72-94, :155-168) DISAGREE The finding needs a job that the under-two-minutes heuristic calls infrastructure and the artifact calls real to be counted as infrastructure. Counter-example, measured live: in run 33339959950 the Style check job failed its Run step in 84 s, so the heuristic scores it infrastructure, while its result_pr.json entry is FAIL with no label. That job is caused by the diff under test and can never pass on a rerun, so folding the two together would take a whole-run rerun of about 170 jobs for a style failure. The class is irreducibly ambiguous, since it also holds real infrastructure failures such as a missing S3 credential, so the design defers to the artifact Finish Workflow reads for Mergeable Check: the retry decision must not disagree with the merge decision. Neither scenario is a regression, because the current workflow also takes no action in both. I recorded the reason in the commit message rather than changing the code.
2 ⚠️ The fork-run measurement reverses its predicate: "empty for 0 of 33 fork heads" states the opposite of the defect it is evidence for AGREE Raised as a nit, recorded major by me, because a pushed commit message can never be corrected. Re-measured independently before fixing, on a fresh 200-run sample: .pull_requests is populated for 0 of 128 fork heads and 71 of 72 same-repo heads, so the defect is real and only the wording was inverted. The commit message and the description now both read "populated for".
3 💡 The shared-commit protection is stated unconditionally, while the implementation only rejects a candidate when one of its own failed-job entries carries a foreign run_url AGREE Correct, and I confirmed the mechanism by reading the code: the classifier iterates only over the candidate's failed jobs, so entries another run wrote for other job names are never consulted, and a candidate whose own entries are all its own is acted on. That is right by construction, since every verdict then comes from that run, and no live counter-example exists: both real shared-commit runs in the 16-pair replay were skipped because their own entries were foreign. Precise form: a candidate is left alone when a concurrent run at the same commit wrote the artifact entry for one of its failed jobs.

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are
terminal per finding. Findings on hunks unchanged by a fix round are auto-dropped.

My own cold reads raised no finding in the shipped logic in any of the three rounds. They
re-measured every count the description and the commit message state: 170 generated jobs, 155
name mismatches against Utils.normalize_string, 191 dict labels beside 1 bare string, 3 jobs
without the pipeline_status guard, 146 of 146 artifact entries joining to the live job ids of
their own run, and a status allow-list that is exactly the five Result.Status values praktika
maps to a failing commit status. All of them hold. Those reads are what bounced the two fix
rounds: an existing comment in ci/praktika/runner.py that this commit made false, two
references to unrelated pull requests cited only as replay data, and a shared-commit figure that
counted commits while naming runs.

Two further imprecisions I found and am disclosing rather than amending, since neither changes
the code or a merge decision. The listed side effects omit that a candidate whose pull request
cannot be resolved at all is now skipped, where the job-level heuristic previously needed no
pull request number; the residual cases are a deleted head branch and a transient API error,
both of which fail closed and are retried on the next tick. And the census behind "3 of 3 uses
of the label" covers the bare-string label only, which has existed since #109673 merged, not the
dict form the integration pre-pull failure has written since 2026-08-24; widening it can only
strengthen the conclusion, because that form was equally unrecoverable. Noted and not chased:
with the predicate now matching both encodings, appending a bare label string rather than calling
set_label is unmotivated, but its only effect is a missing tooltip on an internal report badge.

Session id: cron:clickhouse-review-slot-8:20260831-071900

@clickhouse-gh clickhouse-gh Bot added the manual approve Manual approve required to run CI label Aug 31, 2026
@clickhouse-gh clickhouse-gh Bot closed this Aug 31, 2026
@clickhouse-gh clickhouse-gh Bot reopened this Aug 31, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. The extracted step body driven at RUN_IDS_OVERRIDE=33331951492 takes no action on master and reruns exactly the infra job with this change. Deterministic reads of live GitHub and S3 state, not sampled.
b Root cause explained? The infra label is written correctly and the reader never reaches it: on a fork run the path is gated on a pull request number GitHub does not populate; past that, 155 of 170 job names build a result key that does not exist and the loop breaks on the first; past that, the sub-result test compares lowercase statuses against praktika's uppercase ones; and the only action is a whole-run rerun, correctly refused because the run also failed for real.
c Fix matches root cause? Yes. The name-to-URL reconstruction is deleted rather than patched, so the coupling that produced the mismatch is gone. The blocking status set is derived from Result.Status minus is_ok minus the incomplete pair. The label predicate is the reverted 33b1f35c0ad form restored. No guard is added at the symptom site and no existing check is weakened.
d Test intent preserved / new tests added? No committed test is possible: ci/tests/ was removed from master twice (6fbc634268a4, 813df1fb88f5), and .claude/CLAUDE.md prescribes an uncommitted throwaway instead. The harness is uncommitted and is built by extracting the shipped step body and the shipped jq program out of the YAML, so it cannot drift from the diff. No existing test is touched.
e Both directions demonstrated? Yes, three columns over the same 16 real (PR, commit) pairs: master takes no action on the mixed run 33331951492, this change reruns its infra job, and neutralising the head-commit guard makes run 33331575464 fire too, which is the guard's own reddening arm.
f Fix is general across code paths? The rerun surface is the whole file: grep -ln "run rerun" .github/workflows/*.yml gives this file and create_release.yml, which is release plumbing rather than PR runs. grep -n "tr '[:upper:]'" .github/workflows/*.yml now returns nothing, so the deleted normalization was the only one. The head-commit precondition is applied once for both actions rather than only the new one. The other consumer of the pull request number, the Config Workflow updated-description path, is revived for fork PRs by the same change.
g Fix generalizes across inputs? Covered: both label encodings (bare string and dict), both Checkout Submodules shapes, the full praktika status alphabet (5 blocking, 3 passing, 2 incomplete), a missing entry, an entry with no run_url, an entry stamped by another run at the same commit, an empty results array, an "infrastructure" label that must not substring-match, branch names containing a slash, fork and same-repo heads, a nonexistent head, 0 to 3 infra jobs per run, and 0 to 27 failed jobs per run. The legacy hlabels label form is not matched and is disclosed rather than given a third arm.
h Backward compatible? Yes, and no SettingsChangesHistory.cpp entry applies: no C++, no setting, no serialization format. Every behaviour change is fail-closed except the new per-job action, and the one narrowing of pre-existing behaviour (a run whose commit is no longer its pull request's head is skipped) is stated in the description.
i Invariants and contracts preserved? Every new variable is initialised at the top of the per-run loop, so set -u holds on paths where the classification never runs, which two of the 16 runs exercise. The classifier is strictly narrower than what Finish Workflow treats as blocking: anything that is not an infra label or a Checkout Submodules-only failure falls to a verdict that suppresses a rerun. A single unclassifiable job abandons the whole candidate, so no rerun is issued from an artifact that does not describe this run. set -e is preserved, each tolerated API call carries `

Session id: cron:clickhouse-impl-slot-41:20260831-042400

@clickhouse-gh

clickhouse-gh Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [023b4ac]

Summary: ✅


AI Review

Summary

This PR fixes several real gaps in the hourly infrastructure auto-retry and adds a new partial-rerun path for mixed runs. The remaining issue is that the new "exactly one infra job in a mixed run" recovery is not implemented consistently: Finish Workflow and Config Workflow are still treated as infrastructure failures by the heuristic, but they are filtered out before the new infra counter runs, so a live class of mixed runs still falls through unchanged.

Findings

⚠️ Majors

  • [.github/workflows/retry_infra_failures.yml:141-145] Mixed-run recovery drops Finish Workflow and Config Workflow before counting infra jobs, so runs whose only infra failure is one of those plumbing jobs still do not get the new partial rerun. Recent runs 33371661543 and 33363073433 both failed Fast test plus Finish Workflow; by this file's own heuristic that is exactly one infra job in a mixed run, but the filter leaves infra_count == 0 and the run is skipped. Suggested fix: either include these jobs in the classified set and allow gh run rerun --job to target them, or narrow the PR contract to say the partial-rerun path applies only to non-plumbing jobs.
Final Verdict

Changes needed: the new mixed-run retry path still misses a real class of single-infra mixed runs.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Aug 31, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @maxknv, could you review this? The hourly infra auto-retry never acted on the infra label: the Praktika path was gated on a pull request number GitHub does not populate for fork runs, its result-file names lacked praktika's rstrip("_"), and its failed-sub-result test compared lowercase strings against Result.Status. It now classifies each failed job from that run's own result_pr.json entry, joined by ext.run_url, and reruns the single infra job of a run that also failed for real.

…d run

The hourly auto-retry in `retry_infra_failures.yml` has never acted on the
`infra` label that ClickHouse#109673 added. Five independent defects sit in the same
block, and all of them were measured on live runs.

1. A fork run carries no pull request number. GitHub populates
   `.pull_requests` only for a head branch in the base repository: it is
   populated for 0 of 33 sampled fork heads and for 7 of 7 same-repo heads.
   The whole Praktika-result path was gated on that number, so it was dead on
   every fork pull request. It is now resolved from the head reference when
   absent, which also revives the `Config Workflow` updated-description path
   for fork pull requests.

2. The job-name-to-filename normalization did not match praktika's.
   `Utils.normalize_string` ends with `res.rstrip("_")`, which the workflow's
   `sed` lacked, so every job name ending in a parenthesis built a key that
   does not exist: 155 of the 170 job names in the generated `pull_request.yml`
   mismatch. `curl -sf` treats the resulting 403 as a failure and the loop
   broke on the first one, so one failed parametrized job anywhere in a run
   killed the path. The construction is deleted rather than patched.

3. The failed-sub-result test compared `"failure"` and `"error"` against
   `Result.Status`, which is uppercase, so it was always false and any failed
   job with a readable unlabelled result was classified as infrastructure.
   Fixing only the URL would therefore have started rerunning genuinely
   failing runs; the two had to change together.

4. The label predicate matched only a bare string. `Result.set_label` stores
   labels as dicts, so the docker image pre-pull failure on integration jobs
   writes the dict form. `33b1f35c0ad` fixed exactly this and `7d022e880fef`
   reverted it across every workflow file, asking in its own description for
   the fix to be reapplied separately. One real artifact carries 191 dict
   labels beside 1 bare string, so both encodings must match.

5. The only available action was a whole-run rerun, which is correctly refused
   when the run also carries a real failure. All three runs that have ever
   carried the label are mixed, so 3 of 3 uses of the label were
   unrecoverable.

The classification now reads the run's `result_pr.json` once. That is the same
artifact `_finish_workflow` reads to compute `Mergeable Check`, so the retry
decision and the merge decision can no longer disagree, and it is fresher than
the per-job files. The job-level heuristic's own verdicts are deliberately not
folded into that count: a `Run` step that fails in under two minutes is a
timing proxy that also fires on a real fast failure such as `Style check`, so
inside this path the artifact alone decides. Precedence between the two paths
is asymmetric and unchanged: the artifact is read only when the heuristic has
not already selected the run, so it can promote a candidate the heuristic
rejected but never vetoes one it accepted. Each failed job gets a
three-way verdict joined to the artifact by the entry's own `ext.run_url`: the
S3 key names a pull request and a commit but no run, and 3 head commits in a
200-run sample carried two runs each, so the per-job join is what stops a
candidate being classified from another run's entries. A single unclassifiable
job abandons the whole candidate, because a re-run `Finish Workflow` returns
early on an `OK` entry without consulting GitHub's own job conclusion and
could otherwise post a green `Mergeable Check` over a real failure.

A mixed run with exactly one infrastructure job now has that job rerun.
GitHub's partial-rerun semantics are undocumented, so they were measured on a
purpose-built probe: a per-job rerun re-executes the target, its dependents
and `Finish Workflow`, carries every non-dependent job over with byte-identical
timings and runner, and increments `run_attempt`; a second rerun with a
previous attempt's job id is refused with 403 "Only jobs from the current
attempt can be re-run". A job that had SUCCEEDED is re-executed if it depends
on the target, but only 3 of the 170 generated jobs lack the
`!contains(needs.*.outputs.pipeline_status, 'failure')` guard, so at most one
job that could have passed is affected, and re-running the rest is the
recovery rather than collateral. Exactly one job per run per tick, since the
rerun makes every other job id stale.

Two changes to existing behaviour. `Mergeable Check` is a commit status posted
to the run's own head commit, and a rerun reuses the original event, so a run
whose commit is no longer the head of its pull request can never unblock it;
that precondition now applies to both actions rather than only to the
`Config Workflow` path, which strictly reduces reruns. And a run sharing its
commit with a concurrent run is left alone rather than acted on from a shared
artifact.

`MAX_RERUNS` and the candidate selector are untouched, so the tick's upper
bound is unchanged.

Validated with an uncommitted harness that extracts the step body from the
YAML, driven over the 16 real pull-request-and-commit pairs that produced a
`SQLLogic test` job-level failure in 30 days, beside the same harness running
the unmodified step. The unmodified step takes no action on the mixed run
33331951492; this one reruns its single infrastructure job.

The daemon death itself is a host condition, out of reach here: five distinct
`m8g.4xlarge` hosts lost their daemon inside 36 minutes on 2026-08-30.

Co-Authored-By: Claude Opus 5 <[email protected]>
@groeneai
groeneai force-pushed the fix-retry-infra-failures-praktika-classification branch from f017e0d to 023b4ac Compare August 31, 2026 09:53
@alexey-milovidov alexey-milovidov self-assigned this Oct 10, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 10, 2026
Merged via the queue into ClickHouse:master with commit 1ce237a Oct 11, 2026
174 checks passed
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). groeneai-origin-ci-own-pr PR origin: CI on a groeneai PR exposed a separate defect manual approve Manual approve required to run CI pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants