Skip to content

image: write the resolution record durably - #14

Merged
apostasie merged 1 commit into
mainfrom
claudio/20260913-atomic-writes
Sep 13, 2026
Merged

apostasie merged 1 commit into
mainfrom
claudio/20260913-atomic-writes

Conversation

@closer-claudio

Copy link
Copy Markdown
Contributor

storeResolution wrote the resolve record with os.WriteFile to a fixed temp name and renamed it — no fsync, and a temp name shared by every writer of the same ref. A power loss after the rename could publish a zero-length or torn record; two concurrent runs of the same image could rename each other's half-written bytes. Both read back as a corrupt record → miss → re-resolve, so benign in effect — but a cache trusted on the warm path was not written like one.

Now filesystem.WriteFile from primordium: unique temp in the same directory, write, fsync, close, rename. pkg/volume already did this by hand for the cache image; the record does the same. Still best-effort: a cache-write failure never fails a run.

One function body; just lint and just test green. Both #10 and #13 touch this function and rebase trivially onto it.

storeResolution wrote the record with os.WriteFile to a fixed temp name
and renamed it into place: no fsync, so a power loss after the rename
could publish a zero-length or torn record under the real name; and a
temp name shared by every writer of the same ref, so two concurrent runs
of one image could rename each other's half-written bytes. Both landed
as a corrupt record, which loadResolution reads as a miss and re-resolves
— benign in effect, wrong in kind: a cache that is trusted on the warm
path is written like one.

primordium's filesystem.WriteFile is the drop-in: a unique temp in the
same directory, write, fsync, close, rename. pkg/volume's cache image
already did this by hand; the record now does the same. Still
best-effort — a cache-write failure must never fail a run.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: closer-claudio <claudio@farcloser.world>
@apostasie
apostasie merged commit ca4c3b3 into main Sep 13, 2026
11 checks passed
@apostasie
apostasie deleted the claudio/20260913-atomic-writes branch September 13, 2026 23:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants