atomicWrite and trace appends have predictable temp names and check/open races #152
Labels
No labels
already-shipped
bug
documentation
duplicate
enhancement
external-review
good first issue
help wanted
in progress
invalid
needs-decision
proposal
question
security
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: crenshawdev/cadence-archived#152
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Source: deep dive F12; strict re-review C-18
Verdict: DISPUTE - overstated, closing
Claim as reviewed
atomicWritecomputes a predictable sibling temp name, checks it withlstatSync, then opens it separately, so a path can change between check and open and an existing hard link is followed. The function provides no lock, no exclusive create and no fsync. Trace and read-ledger appenders have the same shape.At HEAD
f354864(v3.3.0)Every mechanical fact is accurate, and every one of them is already stated in the source.
cadence-core/bin/lib/planning-files.mjs:2059-2078- the temp name is<file>.<pid>.<seq>.tmp, unique per call via a module counter, not a fixed sibling.:2028-2039states the full residual: "There is no lock, noO_EXCLretry and nofsynchere - the promise is only that a crash never leaves a torn file", plus the deliberate last-writer-wins behaviour (D-05) and the deliberate overwrite of an ordinary stale temp.cadence-core/bin/lib/trace.mjs:268-297- samelstatSync-then-appendFileSyncshape, with the reasoning stated at:268-270.Note
Winning the check/open window requires write access to
.planning/- the same access someone would use to editROADMAP.mddirectly, which needs no race at all. The stated promise (a crash never leaves a torn file) is met.Closed as an accepted, documented cost rather than a defect. If durability of
.planningstate ever becomes load-bearing, an fsync-before-rename is the change worth revisiting.