Skip to content

id(fileops): claim archive names atomically (resolve+set under one lock) (#2462) - #3012

Merged
dezren39 merged 1 commit into
mainfrom
queue/4353-2462-archive-claim
Oct 31, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/4353-2462-archive-claim

Conversation

@dezren39

@dezren39 dezren39 commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

Fixes #2462 (triage task 3682 pinned the form; queue task 4352's successor fix task 4353).

What

free_archive_name resolved a free archive tag with tags().get and returned it unclaimed; every caller claimed it later with an unconditional tags().set. Two concurrent same-second replaces of one name could resolve the same candidate, and one replaced version's archive was silently overwritten (#2462, the concurrent remainder of #1612 / PR #1706).

  • New claim_archive_name(store, name, ts, hash) in pkgs/id/src/fileops.rs: resolves and sets while holding one process-wide ARCHIVE_CLAIM_LOCK (tokio Mutex), retrying the next suffix inside the same critical section. free_archive_name is now a private helper that may only run under that lock; no caller receives an unclaimed name.
  • All claim sites routed through it: archive_existing (put/rename/copy), rename's archive-original arm, and web archive_original_tag (pkgs/id/src/web/routes.rs).
  • Name shape unchanged: {name}.archive.{ts}, digit-only suffix bumping; the delete/classify_tag suffix contract is untouched.

Single-writer assumption (explicit, per triage): the in-process lock is sound because the id server is the single process writing this iroh-blobs tag store. A second writer process sharing the store would need store-level compare-and-set, which this PR does not build.

Tests

  • New concurrent_same_second_claims_never_collide: 8 barrier-synchronised claims for the same name+second on a multi-thread runtime all land on distinct tags, each holding its own version's hash.
  • Existing same_second_archives_never_overwrite and uncontested_archive_name_is_unchanged ported to the claim API and passing.
  • Laptop: cargo test --lib fileops (in pkgs/id) — 3/3 pass; rustfmt --edition 2024 --check clean on both files.

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner October 31, 2026 09:50
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-31T09:51:50.718404Z 0380366 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 31, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 39 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1552b85b-d238-4f83-8d32-145a7604c294
Commits

Reviewing files that changed from the base of the PR and between 6bbb065 and 0380366.

Files selected for processing: 2
  • pkgs/id/src/fileops.rs
  • pkgs/id/src/web/routes.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

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.

id(fileops): PR #1706's free_archive_name is check-then-act — concurrent same-second replaces can still lose a replaced version's archive

1 participant