Skip to content

Commit 2ac65e3

Browse files
fix(ci): ci-rerun.sh claims a run's reservation with mkdir(2), not the mkdir binary (T133 ci-efficiency a02, revise round 1)
uutils' mkdir ignored EEXIST on a non-recursive creation until uutils bf423f388d (2026-08-28, uutils/coreutils#13970), so on Ubuntu 26.04 both of two concurrent calls for one run "created" its reservation and reran it (PR #409's ubuntu-26.04 canary). python3's os.mkdir makes the mkdir(2) call itself: FileExistsError exits 4, any other failure 1. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent b9b8a5b commit 2ac65e3

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

‎scripts/orchestrator/ci-rerun.sh‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# pull request whose current head is the run's `headSha`, checked before the logs are read and
1111
# again right before the rerun: a superseded head's rerun would re-enter `pr-<N>` and cancel the
1212
# newest head's run. When every such job matches a signature, the run is reserved by an atomic
13-
# `mkdir .orchestration/validation/ci-reruns.lock.d/<run-id>`, one
13+
# mkdir(2) of `.orchestration/validation/ci-reruns.lock.d/<run-id>` (through python3's os.mkdir), one
1414
# `<utc>\t<run-id>\t<headSha>\t<job>\t<signature id>` row per job is appended to
1515
# `.orchestration/validation/ci-reruns.tsv`, and only then `gh run rerun <run-id> --failed`
1616
# runs. The reservation stays after success, failure or interruption, so a run is rerun at most
@@ -129,14 +129,21 @@ done <<< "${candidates}"
129129
((real == 0)) || exit 3
130130

131131
# Reserve before rerunning: the directory and the rows outlive a rerun that fails, is refused or is interrupted.
132+
# The claim is mkdir(2) itself: uutils' mkdir (Ubuntu 26.04) returned 0 for a directory another call had just created,
133+
# until uutils bf423f388d (2026-08-28), so the mkdir binary cannot decide which of two concurrent calls wins.
132134
mkdir -p "${reservation%/*}"
133-
if ! mkdir "${reservation}" 2> /dev/null; then
134-
[[ -d ${reservation} ]] || {
135-
echo "ci-rerun: cannot create ${reservation}" >&2
136-
exit 1
137-
}
135+
claim=0
136+
python3 -I -c 'import os, sys
137+
try:
138+
os.mkdir(sys.argv[1])
139+
except FileExistsError:
140+
sys.exit(4)' "${reservation}" 2> /dev/null || claim=$?
141+
if ((claim == 4)); then
138142
echo "already rerun once: run ${run_id} was reserved by a concurrent call" >&2
139143
exit 4
144+
elif ((claim != 0)); then
145+
echo "ci-rerun: cannot create ${reservation}" >&2
146+
exit 1
140147
fi
141148
now="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
142149
for row in "${matched[@]}"; do

0 commit comments

Comments
 (0)