Build1 distinct publisher3 min readPublished
Duplicate side effects all return 200, so nothing alerts on them. The write side of a file-based guard is a single O_EXCL create and it holds under forty processes; every defect four review rounds found afterwards sat in reclaim and in reads.
The Engineer · Build desk

Compiled by The EngineerSomething wrong?How this is made
Death, more than contention, is what makes this hard. The claim file is a promise that some worker is working, and a SIGKILL or a deploy leaves the promise standing without the worker, at which point the file is a tombstone that blocks that call forever [7]. So the design needs a TTL and a way to take a claim back, and the take-back runs into a constraint most application code never has to see: POSIX has no delete-this-inode, only unlink of a path, and between the moment you judge a claim stale and the moment you remove it, that path can point at a fresh claim somebody else just won [8].
Two processes reading the same stale timestamp are both entitled to act on it. A unlinks, wins the create, starts charging. B, holding bytes it read a microsecond earlier, unlinks A's brand-new claim, wins, and charges the same customer again [9]. The suite stayed green because expiry was probed with a single caller while concurrency was probed from an empty directory, so the defect sat in the gap between two passing tests [10]. Serializing the takeover with a sentinel file and a POSIX flock made the tests green again [12] and left the protected branch as unlink-then-recreate against a timestamp that can be stale, which reproduced twenty double executions out of twenty [14]. The author's own summary is the best line in the writeup: "I had added a lock to guard a copy of the bug I was fixing" [15].
The other finding in that round is quieter and travels further. The lock was scoped to the claim directory rather than to the key, so four unrelated charges that were racing nothing blocked each other and most were refused [16], and the project README rates a missed charge as the worse half of the trade [17]. This is a key-to-path mapping problem, not a locking defect: it decides who competes.
Generations remove the operation rather than debug it: an expired claim stays put, a new `<sig>.genN.claim` opens beside it, and no take-back call exists to get wrong [18]. The acceptance test is a grep that returns zero matches for unlink, rename, os.replace and flock in the guard module [19], which is checkable in CI by someone who knows nothing about concurrency. The clean runs are 0 of 20 forced interleavings, plus 16 workers across 40 trials [20], so 640 executions with no duplicate [23].
Read the 40-to-1 table as a measurement of one host [5]. For it to transfer you need create-exclusive to be atomic on whatever filesystem holds the claim directory, and you need every racing worker to derive the identical path from the identical key. The NFS remark in the source is about flock degrading to a no-op, not about O_EXCL [13], so it certifies nothing about a network share; it warns that a lock layered on top may be decoration.
Adoption cost lands on the reading side. After four rounds of review the eleven open defects were all there [21][22], in questions like how old a claim is when the claim wrote its own timestamp [25].
Ranked by verification strength, evidence, and original report placement.
Monitoring will not flag a duplicate charge because every duplicate returns 200, with green spans and ok log lines; the customer's statement is the only place the incident exists.
The guard's mechanism is one line: fd = os.open(path, os.O_CREAT | os.O_EXCL | os.O_WRONLY, 0o600).
The author describes O_EXCL as a compare-and-swap on existence: exactly one process creates the file and everyone else gets FileExistsError, with no daemon, no Redis and no dependency.
With 40 concurrent OS processes making an identical call, the unguarded path executed 40 times and the guarded path executed 1 (always); the processes were real processes started before any were joined, not threads.
The author says threads would have passed on the GIL alone and proved nothing about production.
A claim is a promise that someone is working; when the holder dies via OOM, deploy or SIGKILL, the promise outlives the worker and the file becomes a tombstone that blocks that call forever, so a TTL and a way to take the claim back are needed.
Distinct publishers with included, body-backed reporting in this cluster.
dev.to
1 article · August 30, 2026
Follow any of these and your For You feed starts watching them — no settings page required.
build
Shared memory in Java: the mmap is the easy half, the descriptor handoff is the work1 distinct publisher
build
Reserving the idempotency key before the gateway call is what wins the race1 distinct publisher
build
Zero errors, one missing workspace: the failure your monitoring is built to miss1 distinct publisher
build
878 tests, zero installs: what agent-built code checks and what nobody encoded1 distinct publisher
Evidence-backed comparisons of source perspectives and observed adoption signals. Read the methodology
Which Builder, Operator, and Investor concerns the observed source mix emphasized—not a truth score.
Evidence, demonstrated adoption, hype gap, incentives, and confidence are assessed independently, each on its own current evidence. How these are measured.
Checkable mechanism, unaudited numbers
Two different grades of proof are mixed here. The reasoning is public property: O_EXCL really is exclusive creation, unlink really does take a path rather than an inode, and a reader can rerun the grep that the author offers in place of a paragraph. The numbers are not: 40 of 40, 20 of 20, 0 of 640 all come off one engineer's machine, in a repository this reporting never names, with no independent run and no test on the network filesystem it identifies as the thing that silently disabled his lock.
No user but the author
Nothing in this reporting shows anyone other than the author running this guard — no dependents, no install counts, no team that shipped it, not even a package or repository name. The executions on record are his own harness, which establishes that the code runs, not that anything depends on it.
One word ahead of the proof
The post argues against itself more often than for itself, which keeps the gap small: the headline result is called 'the easy half', the author's own lock is dismissed as guarding a copy of the bug, and eleven remaining defects are volunteered rather than extracted. The overreach is narrow and specific — 'provably clean' rests on a grep count and 640 executions on one filesystem, and a guard whose stated purpose is surviving OOM, deploys and SIGKILL is never run in the multi-host setting where the same author says flock quietly degrades.
Author auditing his own code
There is no price, no funding round and no vendor in this story, so the pull is reputational rather than commercial. But the confession is also the most flattering structure available to a self-assessment: an engineer who publishes four rounds of his own failures rarely gets asked for the fifth. The defect counts, the verdict on his own lock and the choice of which problems 'are worth your time' all come from the same person, and the unnamed repository means nobody else can grade them.
One voice, verifiable core
We are confident about what this story establishes and unable to test how far it travels. The failure mechanisms hold up on their own terms — path-based deletion racing a fresh claim, a lock that no test misses when removed, a timestamp the claim writes about itself — and none of them depend on believing the author. What no second source touches is whether the numbers reproduce, whether the guard behaves the same off a local filesystem, and whether the eleven read-side fixes settled anything.