Repository navigation
Description
The heavy-suite lock is two locks. A tree at or past #1264 takes a flock on
/tmp/codeaf-suite-<uid>.lockfile. A tree behind #1264 takes the older
directory lock at /tmp/codeaf-suite-<uid>.lock. Neither mechanism can see the
other, so the flock's exclusivity is at present a CLAIM THE BOX DOES NOT HONOUR.
Observed on the box, 2026-09-20T18:35:25Z
A heavy suite running while the flock reads free:
- pid 4029204,
bash ./scripts/one-suite.sh go test -timeout 15m -count=1 -count=1 -p 1 ./cmd/codeaf ./internal/tui3, cwd
/home/santosh/src/cw0918-adaptive-folders, alive. - pid 4029208, its
go test, alive. - That tree is at
991a83d384f5197e99471bb05b4ac8a4d3c1b07e, behind scripts: hold the heavy-suite lock so it works across pid namespaces and dies with its holder #1264. Its
scripts/one-suite.sh:31readslock="/tmp/codeaf-suite-$(id -u).lock", with
the comment explaining that the lock is a directory because mkdir is atomic. /tmp/codeaf-suite-1001.lockexists, created 14:29, and itspidfile
contains4029204, the live process.- At the same instant
flock -n /tmp/codeaf-suite-1001.lockfile -c truereturns
0, free,lsofon that file returns no holder, and the file's contents are a
stale line from an earlier run at 18:12:10Z.
That run is behaving CORRECTLY by its own rules. It holds a lock. It is simply
holding one that current readers do not read.
The failure is symmetric, and only one direction has been hit
DIRECTION ONE, live tonight. A stale tree holds the directory lock. A current
reader checks only the flock, sees free, and starts a second heavy suite beside
it. This is the direction that has been costing us unattributable reds and
timing numbers taken under contention nobody recorded.
DIRECTION TWO, not yet hit and worse. A current tree holds the flock. A stale
tree's runner checks only the directory, sees no holder, and starts beside it.
Same collision, opposite parties, and here the party clobbered is the one that
did everything right.
Dual-checking on the READ side fixes direction one only. It stops a current
reader starting beside a stale holder. It does nothing to stop a stale runner
starting beside a current holder, because that runner will never be taught to
read the flock: being unaware of the flock is what makes it stale.
Immediate remedy, for anything that reads the lock
Wait on the directory lock first and the flock second. Both, in that order. A
gate doing this today can see pid 4029204 and queues behind it correctly.
Durable remedy, for the shared script, and the reason to prefer it
During the transition, the current scripts/one-suite.sh should take BOTH
locks: the flock as now, and the old directory lock as well. It costs a mkdir.
What it buys is that a current tree becomes VISIBLE TO EVERY STALE READER STILL
OUT THERE, without any stale tree being changed. The invisibility then runs in
one direction only, and that direction is the safe one: a stale runner sees a
current holder and waits. Direction two closes without touching anything that is
behind the head.
The transition ends when nothing running on the box is behind #1264. Until
somebody can assert that, dual-hold is what makes the flock's claim true rather
than merely declared.
Consequences worth recording while this is open
- Any
suite_lock_heldfield written by a flock-only reader is false on exactly
the runs where it matters. - A ceiling that lowers while a suite holds the lock has not been lowering for
these runs. - Timing numbers taken "under the lock" during the transition are upper bounds
with an unknown floor, and should be quoted that way rather than discarded.
Raised as an issue and not a patch because it changes a shared script that other
trees run.
Drafted with CodeAF · reviewed and owned by the author
Activity
santoshkumarradha commentedon Sep 20, 2026
Filed #1320 for a hole that none of the remedies here close, and recording the boundary so a reader of this issue does not over-credit its fix.
This issue is two lock mechanisms that cannot see each other, both of which are trying to participate. #1320 is a runner that never enters the scheme:
go test ./internal/sessiontyped directly. The binding inMakefile:126is between the make TARGET and the lock, not between the PACKAGE and the lock, and the package is what loads the box.So dual checking on the read side, and taking both locks in
scripts/one-suite.sh, could both land tomorrow and #1320 would be exactly as open. Observed live on 2026-09-20T19:25Z: a correct holder throughmake checkand an unlockedgo test ./internal/sessionalive at the same instant, box load 14.52.scripts: the suite does not inherit the lock's name, and the lock nam…
santoshkumarradha commentedon Sep 23, 2026
Fixed on
santos/dev2by #1324 (d57f26d) and #1392 (c61615a).scripts/one-suite.shnow takes both locks, andcmd/codeaf-suite-lockimplementstakeDirLock,dropDirLock, andreclaimDirLock.Closing as done.
drafted with CodeAF