GeezerVison is showing github.com — id(fileops): PR #1706's free_archive_name is check-then-act — concurrent same-second replaces can still lose a replaced version's archive · Issue #2462 · developing-today/code
id(fileops): PR #1706's free_archive_name is check-then-act — concurrent same-second replaces can still lose a replaced version's archive #2462Labels app/idPackage/app: id (pkgs/ or apps/ in this repo)effort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/lowNice to have; do when convenientsource/pr-diff-reviewFiled by the pr-diff-review jobtask/triageQueue packet kind: verify, reproduce, and route this item Descriptionid(fileops): PR #1706's free_archive_name is check-then-act — concurrent same-second replaces can still lose a replaced version's archive
Finding
PR #1706 (merged, fixes #1612) made archive tag names unique for the sequential case: free_archive_name (pkgs/id/src/fileops.rs:107 on current main 5a34fa70) loops store.tags().get(candidate) until it finds a free {name}.archive.{ts} name, and the caller only afterwards claims it with tags().set. The check and the claim are two separate awaited store operations with nothing serialising them, and iroh-blobs tags().set is an unconditional write — the same check-then-act shape as #2363 (the upload uniquifier), at a different site.
Interleaving that still loses data, for two concurrent replaces of the same name in the same second (rename/copy at fileops.rs:260/:346, put, or the web save path via archive_original_tag at web/routes.rs:2209, called at routes.rs:1261):
- A reads current hash v1,
free_archive_name returns doc.archive.{ts}.
- B reads current hash v1,
free_archive_name also returns doc.archive.{ts} (A has not set it yet).
- A sets
doc.archive.{ts} = v1, then sets doc = v2.
- B sets
doc.archive.{ts} = v1 (same value, harmless), then sets doc = v3.
v2 was live and is now referenced by no tag: it was never archived, so it lost exactly the archive/GC protection #1612 exists to provide. The PR's regression tests (fileops.rs:464 same_second_archives_never_overwrite) are sequential — each archive is fully set before the next name is resolved — so they cannot see this window.
Evidence
- PR: id(fileops): unique archive tag names so same-second replaces never overwrite (#1612) #1706 — merge
d29f867ca765f1e89025d9c499ac25d1e46ffa2b, head commits 5fb1d2cf, a3be7eeb.
- Current main
5a34fa70: free_archive_name at pkgs/id/src/fileops.rs:107-118 (get-loop, returns unclaimed name); claim sites archive_existing (fileops.rs:173, set follows at its end), rename (:260), copy (:346), web archive_original_tag (web/routes.rs:2209, used at :1261).
- No lock/mutex serialises these paths:
grep Mutex/lock pkgs/id/src/web/routes.rs shows only the unrelated local_events lock; FileOps holds no lock field.
Why it matters
The archive tag is the only reference keeping a replaced version alive for GC. The sequential same-second collision #1612 reported is fixed, but the concurrent case — two clients/CLI processes against one store, or a web save racing a rename — silently drops a version's archive with no error anywhere.
Acceptance criteria
- Two concurrent same-name replaces within one second both leave an archive tag pointing at their respective replaced versions (a regression test that interleaves the two
free_archive_name resolutions before either claim, or an equivalent concurrency test, fails before and passes after).
- The claim is made atomic or serialised (e.g. a set-if-absent claim loop inside
free_archive_name's callers, or a per-store lock around resolve+claim) at all three call sites including the web layer's archive_original_tag.
- Sequential behaviour and name shape unchanged: uncontested name is exactly
{name}.archive.{ts}; existing archive_name_tests and protocol archive tests still pass (in CI).
Found by pr-diff-review lane B reviewing PR #1706. Sibling, not duplicate: #2363 covers the upload-name uniquifier in upload_handler; this is the archive-name path from #1612. Activitydeveloping-today commented on Oct 29, 2026 dezren39 commented on Oct 29, 2026 dezren39 commented on Oct 31, 2026 agent-note:v1
event: parked
task: 4353 (lane C)
reason: CI pending on PR 3012 — no PR workflow run has started ~30 min after open (fleet runner backlog). Codex review on head 0380366: no findings. Diff verified in-scope (pkgs/id/src/fileops.rs + pkgs/id/src/web/routes.rs). Resume: CI green -> merge PR 3012 -> close this issue. dezren39 commented on Oct 31, 2026
🤖 Agent note · picked up (resume)
dezren39 commented on Oct 31, 2026
🤖 Agent note · done (fix merged)
- Agent: queue worker (repo-worker-code), lane B shift
- Session / ID: queue task 4353
- Found via: queue claim (resume)
- Task: id(fileops) atomic archive-name claim — PR id(fileops): claim archive names atomically (resolve+set under one lock) (#2462) #3012 merged (
ab55f3c256cd53cb3cbab25ccc8eb61b2afc768b), this issue closed by the merge.
- Verification (first-hand this shift): Codex review completed on head 0380366 with zero findings and 0 unresolved threads; diff is exactly the two in-scope files (+113/−34) with all three claim sites routed through
claim_archive_name (fileops.rs archive_existing + rename arm, routes.rs archive_original_tag:2249); laptop cargo test --offline -p id fileops exit 0 — 3/3 archive tests pass, including the new barrier-synchronised concurrent_same_second_claims_never_collide and the pre-existing same_second_archives_never_overwrite.
- CI note: no CI workflow ever started on this branch (~1h, fleet runner backlog — infrastructure, not the change). Merged under the standing merge directive on the strength of the laptop test verification + clean Codex review; if post-merge CI surfaces a problem in this change, fix forward.
MetadataMetadataapp/idPackage/app: id (pkgs/ or apps/ in this repo)effort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/lowNice to have; do when convenientsource/pr-diff-reviewFiled by the pr-diff-review jobtask/triageQueue packet kind: verify, reproduce, and route this item DevelopmentNo branches or pull requestsIssue actions
|