Skip to content

Commit 0ec088b

Browse files
committed
test(ctags): lock the failed fake ctags start with set -C, not mkdir
TestStartSemanticCtagsParsersClosesTheStartedParsers failed on the ubuntu-26.04-arm runner of CI run 40719104932: "started workers [] (err=<nil>), want 3". The fake ctags script picked the one failed start with `mkdir "$ZQ_CTAGS_DIR/failed"` as a lock. Ubuntu 26.04 ships the uutils (Rust) coreutils. Before 0.11.0, uutils mkdir exits 0 when a concurrent call has made the folder first (uutils/coreutils#13970). So all four concurrent starts took the failed branch, and no worker started. The script now creates the lock file with the shell's noclobber option: `(set -C; : >"$ZQ_CTAGS_DIR/failed")`. The shell opens the file with O_EXCL, so exactly one start creates it, with any coreutils. The production code (startSemanticCtagsParsers) did not change. Checks: a PATH shim mkdir that exits 0 on an existing folder gave the CI message 5 times in 5 before the change; after it, the test passes 50 times in 50 with the shim, 50 in 50 without it, and 20 in 20 with -race and the shim. A /bin/dash stress run (16 starts at the same time, 200 rounds) gave exactly one winner in each round.
1 parent a98f2ec commit 0ec088b

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎cmd/seek/semantic_build_test.go‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1105,11 +1105,16 @@ func TestBuildSemanticFolderGenerationFailsOnTransientRead(t *testing.T) {
11051105
// TestStartSemanticCtagsParsersClosesTheStartedParsers starts four ctags
11061106
// workers at the same time. One start gets a fatal error, and the three others
11071107
// start. The start returns that error and stops the three ctags processes.
1108+
// The script selects the failed start with set -C: the shell then creates the
1109+
// file with O_EXCL, so exactly one start creates it. The script does not use
1110+
// mkdir: before 0.11.0, the uutils mkdir of the Ubuntu 26.04 runners exits 0
1111+
// when a concurrent call has made the folder first
1112+
// (https://github.com/uutils/coreutils/issues/13970).
11081113
func TestStartSemanticCtagsParsersClosesTheStartedParsers(t *testing.T) {
11091114
dir := t.TempDir()
11101115
command := filepath.Join(dir, "ctags")
11111116
writeExecutable(t, command, `#!/bin/sh
1112-
if mkdir "$ZQ_CTAGS_DIR/failed" 2>/dev/null; then
1117+
if (set -C; : >"$ZQ_CTAGS_DIR/failed") 2>/dev/null; then
11131118
echo '{"_type":"error","message":"zqfatal","fatal":true}'
11141119
exit 1
11151120
fi

0 commit comments

Comments
 (0)