Repository navigation
fix(lock): queue and report on a contended flock instead of failing at 2m0s - #132
Conversation
…t 2m0s
A blocking acquire gave up after 2 minutes and named nobody. Measured in a check
bed as
acquiring build lock for githubrunner: flock ~/.cache/charly/locks/image-<sha8>.lock:
lock held by another process for > 2m0s
(check run 2026.255.2310) while the holder was a PEER cold-building the SAME
image — a legitimate hold (a cold image build measured up to ~26 min in the
beds), not a stuck one. The correct behaviour is to queue: the peer finishes and
the waiter then cache-hits.
- lockTimeout 2m -> 30m: a bounded wait that covers a cold image build with
headroom (still bounded — the deploy-del stall guard is unchanged).
- flockBounded reports WHILE it waits (holder, elapsed, giving-up bound), so a
legitimate minutes-long queue is distinguishable from a hang.
- the timeout error NAMES the holder (pid + command line) and says what to do,
resolved from the KERNEL: /proc/<pid>/fdinfo carries the lock file's inode
and the flock. The lock file itself stays content-free (the deletion the
package's tests pin shut) and a DEAD holder can never be reported, because
the kernel drops its flock on exit; the lookup degrades to plain text where
/proc cannot answer.
- the deploy-del regression guard is renamed ...FailsFast... ->
...BoundedOnContendedLock: the bound still terminates, but "fast" stopped
being true once the per-image lock's normal hold became minutes.
Review — PASSHead SHA: Security screen: PASS — no scope mismatch (new Checklist: All applicable rules PASS or NA — one atomic commit; RCA replaces the 2 m bound (premise re-examined: slow vs stuck holder) rather than tolerating the failure; hard replacement, no dual-mode/legacy path; new tests fail without the change (timeout message, wait report, holder scan, fallback); no candy/schema/wire change → ADE/SDD/CUE NA; placement CORRECT (kind-blind diagnostic helper co-located with the lock primitive, no capability pulled into core); the contended-load failure is answered with a real external-holder queue demo, not an idle re-run; cross-repo consumer/pin work is structurally forced by pin discipline, not a vague deferral. Tool-limited disposition: pasted test/probe output and the repo-root rulebook check cannot be re-run read-only — cross-checked as internally consistent with the diff (pre-change message format matches the pasted failure, 30 m bound/30 s cadence/holder pid resolution all match the code). No comments on the thread to disposition. Verdict: PASS opencode/deepseek-v4.1-flash — action-review. |
[step: review]Review — PASSHead SHA: Security screen: PASS — no scope mismatch (new Checklist: All applicable rules PASS or NA — one atomic commit; RCA replaces the 2 m bound (premise re-examined: slow vs stuck holder) rather than tolerating the failure; hard replacement, no dual-mode/legacy path; new tests fail without the change (timeout message, wait report, holder scan, fallback); no candy/schema/wire change → ADE/SDD/CUE NA; placement CORRECT (kind-blind diagnostic helper co-located with the lock primitive, no capability pulled into core); the contended-load failure is answered with a real external-holder queue demo, not an idle re-run; cross-repo consumer/pin work is structurally forced by pin discipline, not a vague deferral. Tool-limited disposition: pasted test/probe output and the repo-root rulebook check cannot be re-run read-only — cross-checked as internally consistent with the diff (pre-change message format matches the pasted failure, 30 m bound/30 s cadence/holder pid resolution all match the code). No comments on the thread to disposition. Verdict: PASS opencode/deepseek-v4.1-flash — action-review. |
Summary
A blocking
AcquireFileLockgave up after 2 minutes and named nobody. Measured in a real check bed (run2026.255.2310, thecheck-githubrunner-podimage-build step):The holder was a peer cold-building the SAME image — a legitimate hold (a cold image build measured up to ~26 min in the beds:
pod-immich-ml/cachyosimage-build 1529 s), not a stuck one. The correct behaviour is to QUEUE: the peer finishes, and the waiter then cache-hits. Any two concurrent check beds that share an intermediate therefore turned into a hard failure of one of them, at a bound shorter than one cold build.What changed
lockTimeout2m → 30m. The bound must exceed the longest LEGITIMATE hold or a healthy peer is reported as a failure. 30 m covers the longest measured cold build (~26 min) with headroom and stays bounded — the deploy-del guard (never an unbounded flock) is untouched.flockBoundedreports WHILE it waits. EverylockWaitReportInterval(30 s) a waiting acquire prints to stderr what it is waiting for, who holds it, how long it has waited, and when it will give up. Without this a legitimate minutes-long queue is indistinguishable from a hang — this is the difference between a reported wait and a silent stall./proc/<pid>/fdinfo/<fd>carries the locked file's inode AND the lock (lock:\t1: FLOCK ADVISORY WRITE <pid> <maj:min:ino> 0 EOF), so a waiter matches the inode, resolves the pid, and reads its command line. This is deliberately not a pid line written into the lock file: the file stays content-free (the removal thoseWritesNothing/TruncatesStaleContenttests pin shut), a dead holder can never be named (the kernel drops its flock on exit), and a waiter that has merely OPENED the file is never mistaken for the holder (it has nolock:line). Where/proccannot answer (non-Linux, kernels without fdinfo locks) the description degrades toanother process (holder not identifiable on this platform)— the WAIT is unaffected.TestAcquireFileLock_FailsFastOnContendedLock→TestAcquireFileLock_BoundedOnContendedLock(the bound still terminates, but "fast" stopped being true once the normal hold became minutes) with the doc comment updated.Follow-on (NOT in this PR)
The consumer is opencharly/charly (
charly/go.modrequiresgithub.com/opencharly/spec) — the new semantics reach charly's own sibling build lock (charly/plugin_loader.go's plugin-binaryAcquireFileLock) only through a spec pin bump, which lands as its own charly PR (together with the call-site message hardening). Likewisecandy/plugin-build'sacquiring build lock for %swrap (podman.go:37, wrapped bydrive.go:158) now carries the holder identity through%w; its call-site message is a separate plugin-build PR. This PR deliberately contains neither (pin discipline / one repo per PR).How tested
1. Full gate — the repo's own CI (
ci.yml: Build / Test / gofmt / golangci-lint v2.13.2)2. The package's own tests, including the PRE-EXISTING contract this change must not break
The two content tests (
WritesNothing,TruncatesStaleContent) still pass unchanged — this change adds no bytes to a lock file.3. Live end-to-end queue: a REAL external holder, a real waiter, the real exported API
(pid 3574641 is the
sleepchild, which inherits the file description the flock lives on — both processes genuinely hold it; the holder list reports what the kernel reports.)4. What was NOT run
No
charlybuild-contention bed run was staged here. The pre-fix failure it would reproduce is already an artifact from the real run (2026.255.2310, pasted in Summary), and the changed path ran live above (section 3) with the full gate green on the final tree (sections 1–2). A bed-level re-run belongs to the consumer once the pin bump lands.Rulebook compliance
(
opencharly/specships no AGENTS.md/CLAUDE.md — verified at the repo root — so the umbrella rulebook governs.)/tmp/ws-spec= github.com/opencharly/spec) and landed by PR; the umbrella gitlink is untouched.git -C <absolute path>) — HOW: every git command usedgit -C /tmp/ws-spec.go.work) — HOW: none added; the module builds standalone (go build ./...)./tmp, not a worktree.go.mod) bumps to this PR's merge tag in its own PR./charly-internals:git-workflowloaded before the first tool call.fails fastdocs/name are corrected in-PR.git statusclean before commit; branchfeat/lock-queue-and-report; no force-push, no hook bypass, no direct push tomain.ci.yml) ran on the final tree; output pasted.Change classification
lock) — no schema/CUE change, no wire change, no API change (all exported signatures unchanged), no pin.ci.yml:go build ./...,go test ./...,gofmt -l .,golangci-lint run ./...) — PASSED on the final tree; plus the live external-holder queue demo and the package's own pre-existing content tests still green.fully tested and validated— the repo's full gate passed on the final tree and the changed path (blocking acquire → bounded queue with live holder report → acquire on release) executed live; the one thing a stronger claim could add is a consumer-sidecharlybuild-contention run, which lands with the charly pin bump (section "Follow-on").Assisted-by: pi ollama-cloud/deepseek-v4.1-flash (fully tested and validated)