fix(ci): stop merge-train PRs running the same commit multiple times#24433
Open
charlielye wants to merge 1 commit into
Open
fix(ci): stop merge-train PRs running the same commit multiple times#24433charlielye wants to merge 1 commit into
charlielye wants to merge 1 commit into
Conversation
Merge-train PRs are deliberately exempt from CI cancellation so each distinct train commit is tested. But the concurrency group keyed on github.run_id (unique per run), which never collapses anything — so duplicate pull_request events for the SAME commit (synchronize + the bot re-applying ci-no-squash / ci-full-no-test-cache labels) each spawned their own run. Observed: 3 identical CI runs for one commit, each launching an EC2 box with the same name, racing bootstrap_ec2's same-name reap (a check-then-launch race) so all 3 survived. - ci3.yml: key the merge-train concurrency group on head.sha, not run_id, so same-commit duplicate events collapse while distinct commits still run concurrently. Non-merge-train / merge_group / push are untouched (the changed operand is only selected for merge-train heads). - bootstrap_ec2: append the commit sha to merge-train instance names so the distinct commits that DO run concurrently get their own boxes instead of colliding / reaping each other. Connect helpers match the Name tag by substring, so the sha-free base name still resolves them.
ludamad
approved these changes
Jul 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A single merge-train commit spawned three concurrent CI runs (observed on PR #24431 for commit
b7940093a5— threepull_requestruns, same SHA, same second), each launching its own EC2 box with the identical name.Root cause
Merge-train PRs are intentionally exempt from CI cancellation so each distinct accumulated train commit gets tested. But the concurrency group keyed on
github.run_id:github.run_idis unique per run, socancel-in-progressnever collapsed anything — including duplicatepull_requestevents for the same commit. When a sub-PR merges intomerge-train/spartan, the bot fires a burst at one SHA: asynchronizeplus re-applying theci-no-squashandci-full-no-test-cachelabels (thelabeledtype is enabled). Each became its own uncancellable run.Those runs then all built the same instance name (
aztec-packages_merge-train_spartan_amd64_x-full-no-test-cache) and racedbootstrap_ec2's same-name reap (a check-then-launch race), so all three boxes survived.Fix
ci3.yml— key the merge-train concurrency group ongithub.event.pull_request.head.shainstead ofgithub.run_id. Same-commit duplicate events now collapse (cancel-in-progress); distinct commits still run concurrently. Non-merge-train PRs,merge_group, andpushare untouched — the changed operand is only selected when the head ref ismerge-train/*(for everything elsestartsWith(...)is false and the expression falls through tomerge_group.head_ref || ref_nameexactly as before).bootstrap_ec2— append the commit sha to merge-train instance names, so the distinct commits that do run concurrently get their own boxes instead of colliding / reaping each other.ci.sh's connect helpers match the Name tag by substring, so the sha-free base name fromaws_instance_namestill resolves them.Verification
merge-train/spartan; confirm thesynchronize+ twolabeledevents collapse to one in-progressci3run for that SHA and exactly one instance is requested.