Repository navigation
Do not run two PR workflows at the same commit - #116701
Conversation
A PR that is opened and then reopened seconds later delivers two pull_request events at one head commit, so GitHub dispatches two complete PR workflow runs in parallel. Both are run_attempt = 1, and TEMPLATE_PULL_REQUEST_0 emits no concurrency block, unlike TEMPLATE_SCHEDULE and TEMPLATE_DISPATCH_WORKFLOW, so neither run supersedes the other. Everything the two runs share is keyed by (PR, sha) and never by RUN_ID: the S3 artifact objects from _Environment.get_s3_prefix_static, and the result_<workflow>.json document merged by _ResultS3.update_workflow_results. Two consequences measured at one commit of ClickHouse#116641 and of ClickHouse#116642: - Nine legs of one run died in the praktika pre-run artifact download with PreconditionFailed, because the other run re-uploaded the key while the ranged GET was in flight, so its ETag precondition no longer held. All nine are success in the sibling run at the identical tree, and two of them are flaky check legs. praktika had already closed this same race for the submodule cache object alone, with an If-None-Match write-once create in native_jobs.py. - The losing run's Finish Workflow read the shared result document while the other run's per-arch jobs were still RUNNING, and published "No per-arch Bugfix Validation job validated the bug". The sibling run contradicts it with three success jobs. Emit a concurrency group of workflow, PR number and head sha, with cancel-in-progress, for pull_request workflows. The head sha is in the group so a push starts a new group and never cancels the run at the previous commit. When the second run appears the first has created exactly one job, Config Workflow, so a supersession cancels that job and nothing else. The group is populated per event rather than written into the template, because TEMPLATE_PULL_REQUEST_0 is shared with the push workflows, where github.event.pull_request is null. A literal in the template would give MasterCI a degenerate group and, with cancel-in-progress, cancel every in-flight run on every master commit. master.yml and release_branches.yml stay byte-identical. The close-and-reopen originates from an app outside this repository. This change neither depends on it nor alters it, and a genuinely reopened PR still gets a run. retry_infra_failures.yml partially masks this today: a pre-run S3 failure is classified as infrastructure by its rule for a Run step that failed in under two minutes, and the run is retried. 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; 0 findings) plus my own cold The independent pass read the generator in full, its callers, every event sibling and the My own review found four nits and no blocker or major. Three were defects in the PR body and
What I checked myself and could not turn into a finding: the brace count in the new template Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-11:20260827-115300 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-41:20260827-112800 |
|
Workflow [PR], commit [4a58024] Summary: ✅ AI ReviewSummaryThis PR adds a top-level Final Verdict✅ No new findings. |
|
cc @leshikus @maxknv, could you review this? A PR reopened seconds after opening delivers two |
`_check_yaml_up_to_date` only compares the committed YAML against a fresh
regeneration, so removing `{CONCURRENCY}` from `TEMPLATE_PULL_REQUEST_0` and
committing the regenerated files keeps CI green while both `pull_request`
workflows silently lose the group: measured, `praktika yaml` exits 0 and
`pull_request.yml` and `backport_branches.yml` come back without it.
The generator now refuses to emit a `pull_request` workflow that has no group,
and refuses to emit any other workflow that references
`github.event.pull_request`. `Config Workflow` regenerates on every run of
every workflow, so the check is enforced in CI and locally alike.
Checking only for `concurrency:` and `github.event.pull_request.number` still
passed after `cancel-in-progress: true` was dropped, and after the head sha was
dropped from the group, because the sha also reaches the rendered file through
`CHECKOUT_REF`. Comparing against `TEMPLATE_CONCURRENCY_PR` itself is no
better: mutating the template mutates both sides of that comparison, so
deleting `cancel-in-progress: true` from it leaves `praktika yaml` at exit 0
and a rendered `pull_request.yml` with no such line.
Spelling the expected block out at the assert makes each of the four mutations
that break the contract fail generation: `{CONCURRENCY}` removed from
`TEMPLATE_PULL_REQUEST_0`, `cancel-in-progress` removed, the head sha removed,
the pull request number removed.
The only job blocking `Mergeable Check` on the previous head was `Stress test (arm_asan_ubsan)`, a `DB::collectSets` stack exhaustion that fired on eight unrelated pull requests and is fixed on master by ClickHouse#116978. ClickHouse#116701, also now on master, stops two PR workflows running at the same commit, which produced the other two reds on that head. Neither commit was reachable from this branch.
Related: #116641
Related: #116642
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Give the
pull_requestworkflows a concurrency group so two runs cannot race at one commit.Description
A PR is opened and reopened seconds later, so two
pull_requestevents dispatch two fullPRrunsat one head commit. Both are
run_attempt = 1and neither supersedes the other, because thegenerated workflow has no
concurrencyblock. praktika keys their shared state by(PR, sha),never by
RUN_ID, so each run overwrites the other's S3 artifacts and reads its in-flight statusesfrom
result_<workflow>.json.On #116641 nine legs of one run died in the pre-run download with
PreconditionFailed:the other run re-uploaded the key mid-download, invalidating the ranged GET's ETag. All nine are
successin the sibling run at the identical tree, two of themflaky check. On #116642 thelosing
Finish Workflowread that shared document mid-run and publishedNo per-arch Bugfix Validation job validated the bug, which the sibling run contradicts with threesuccessjobs.This adds a
concurrencygroup of workflow, PR number and head sha withcancel-in-progress, forpull_requestonly. The head sha is in the group, so a push starts a new group and never cancelsthe previous run.
master.ymlandrelease_branches.ymlshare the template and staybyte-identical, because
github.event.pull_requestis null on a push. The generator now refuses toemit a
pull_requestworkflow without that block, or another workflow referencing it.The close-and-reopen comes from an app outside this repository that this change does not touch.
Residuals:
CacheRunnerHooks.pre_runcan still aim a download at another PR's prefix,any_bugfix_validation_passedstill reads aRUNNINGper-arch job as a refutation, andFinish Workflowis emitted withalways(), so the group cannot stop a superseded finalizer thatalready started; in the measured 8-second window only
Config Workflowexists.The two runs and their shared report:
33040674324,
33040682270,
report.
Workflow [PR]
Sync PR [sync-upstream/pr/116701]
Version info
26.9.1.513(included in26.9and later)