Repository navigation
fix(scripts): decide the ctl lock by a noclobber pid file, not by mkdir's exit status - #23
Merged
Merged
Conversation
Each concurrent start runs under sh -x with its output kept; when the test fails it prints the three traces with exit codes and timings, the pidfiles, the lock directory and its pid file, the children file, the copies the fake recorded and the test's processes. The fake now also records its own pid. ci: let both Python legs finish (fail-fast: false), so a failure on one leg no longer hides the result of the other.
…ir's exit status uutils mkdir, the default mkdir on Ubuntu 26.04 (ubuntu-latest), reports success to a call whose directory a concurrent call created a moment before: in a 3-way race on a fresh path, more than one call succeeded in 830 of 2000 rounds (GNU mkdir: 0). Two concurrent starts then both held the lock and both started a copy. A call now holds $LOCK (and $LOCK.reclaim) only when it also creates the pid file inside under noclobber, which the shell opens with O_EXCL. A call that loses leaves the directory alone, and release removes the file, then the directory, never recursively.
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.
test_concurrent_starts_run_one_copy(and its stale-lock variant) started one copy too many now and then onubuntu-latest, never locally. Each concurrent start now runs undersh -xwith its output kept, and a failure prints the three traces, the pidfiles, the lock, the children and copies the fake recorded, the copies' output and the script'sstatusverdict.The dumps show a lock breach, not a liveness misjudgement. In an Ubuntu 26.04 container, two calls each took
$RUN/board.lockwith one plainmkdir(no wait, no stale check), both started a copy, and the first call's release found the other's pid in the lock ([ <pid B> <start> = <pid A> <start> ]). On a hosted runner (stale-lock variant), two calls both "created"$RUN/board.lock.reclaim, both removed the stale lock, and the secondrmdirof the reclaim directory failed with "No such file or directory".Cause:
ubuntu-latestis now Ubuntu 26.04, whose defaultmkdiris uutils coreutils 0.10.0 (printed on the runner). It reports success to a call whose directory a concurrent call created a moment before. In a 3-way race on a fresh path, more than one call succeeded in 830 of 2000 rounds; GNUmkdir(24.04, orgnumkdiron 26.04) in 0 of 2000. The lock relied onmkdirbeing exclusive. Every failing hosted run checked, the first one included, ran on the 26.04 image.Fix: a call holds
$LOCK(and$LOCK.reclaim) only when it also creates the pid file inside under noclobber (set -C), which dash opens withO_CREAT|O_EXCL;mkdirsuccess stays a precondition, so a pidless lock directory is still respected. A call that loses leaves the directory alone, and release removes the file, then the directory, never recursively. On-disk layout is unchanged (<pid> <start>in$LOCK/pid); the lock section stays identical in the three scripts. A new test runs the concurrent starts with amkdirthat always reports success. Probe of the new primitive (mkdir, then noclobber file): no round with more than one winner: 0 of 2000 on 26.04 dash with uutils, 0 of 2000 on 24.04 dash with GNU, 0 of 1000 with bash as sh.Reproduction, Ubuntu 26.04 container (dash, uutils mkdir,
--cpus 2), 40 rounds of the concurrent tests per Python:--cpus 2and two pinned CPUs).The failures are not tied to Python 3.13: only 3.13 happened to fail on hosted runners (1 of 20 repeated rounds against 0 of 20 for 3.10), and 3.10 fails as well in the container. CI now sets
fail-fast: falseon the test matrix so both legs always finish. Whichmkdira Termux device ships was not checked here; the fix does not depend on it.