Space registry (spaceids.json) still writes through a fixed .tmp name: concurrent writers can corrupt it (#742) #1007

Closed
opened 2026-10-26 04:25:17 +00:00 by Cordy · 1 comment
Owner

Found in the batch 7 final review (.superpowers/sdd/2026-10-26-batch7/final-review.md). The space registry writes with the fixed temp name. v0.6.354 introduced statestore.WriteShared (unique temp name, safe for concurrent writers) but used it only for the shared documents tlsstatus.json, tlsalerts.json, spacealerts.json, spacefolders.json, device-pauses.json and oidc-groups-claim.json.

With several instances on one posix state directory (#742 comment 9729 item 1), two registry writes at once can rename a half-written file or fail with "no such file". v0.6.355 makes the registry carry group bindings, so it matters more now.

Fix: move the registry (and any other multi-writer state file still on statestore.Write) to WriteShared with read-merge-write. Add a test with two writers on one directory.

Found in the batch 7 final review (`.superpowers/sdd/2026-10-26-batch7/final-review.md`). The space registry writes with the fixed temp name. v0.6.354 introduced `statestore.WriteShared` (unique temp name, safe for concurrent writers) but used it only for the shared documents `tlsstatus.json`, `tlsalerts.json`, `spacealerts.json`, `spacefolders.json`, `device-pauses.json` and `oidc-groups-claim.json`. With several instances on one posix state directory (#742 comment 9729 item 1), two registry writes at once can rename a half-written file or fail with "no such file". v0.6.355 makes the registry carry group bindings, so it matters more now. **Fix:** move the registry (and any other multi-writer state file still on `statestore.Write`) to `WriteShared` with read-merge-write. Add a test with two writers on one directory.
Cordy referenced this issue from a commit 2026-10-26 10:56:45 +00:00
Author
Owner

Fixed in v0.6.356 (PR #1014), live on both dogfoods since 2026-10-26 11:45. Both pods started cleanly with no new WARN or ERROR.

  • statestore.Write and the local store save now use a unique temp name for every write (fixing the shared .tmp race), as do bootstrap, segments and tus.
  • The space registry already merged its records, so only the temp name changed there.
  • spaces.json, spacemeta.json and spacequota.json now re-read and merge before writing, and refuse to overwrite a file they cannot read. A new space that ends up uncapped gets a WARN.

The audit of all 35 callers is in .superpowers/sdd/2026-10-26-batch8/task-b-report.md. The remaining whole-file writers are tracked in #1011 (High once instances share state); the marks secret in #1012 and the raw errors to owners in #1013. Closing.

Fixed in **v0.6.356** (PR #1014), live on both dogfoods since 2026-10-26 11:45. Both pods started cleanly with no new WARN or ERROR. - `statestore.Write` and the local store save now use a unique temp name for every write (fixing the shared `.tmp` race), as do bootstrap, segments and tus. - The space registry already merged its records, so only the temp name changed there. - `spaces.json`, `spacemeta.json` and `spacequota.json` now re-read and merge before writing, and refuse to overwrite a file they cannot read. A new space that ends up uncapped gets a WARN. The audit of all 35 callers is in `.superpowers/sdd/2026-10-26-batch8/task-b-report.md`. The remaining whole-file writers are tracked in #1011 (High once instances share state); the marks secret in #1012 and the raw errors to owners in #1013. Closing.
Cordy closed this issue 2026-10-26 11:50:03 +00:00
Sign in to join this conversation.
No labels
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Cordy/Cairn#1007
No description provided.