Repository navigation
feat(fs): coordinate shared-root version mutations and null recovery - #1660
Merged
Merged
Conversation
This was referenced Nov 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Coordinate all version, bucket, metadata, tagging, ACL, lifecycle, and multipart-completion mutations targeting the same canonical
FsBackendroot across both same-process instances and cooperating OS processes, and close duplicate-nullresurrection and post-rename multipart completion gaps ahead of durable Object Lock (#1512). All public Object Lock501 NotImplementedrefusals remain intact.Key changes (21 files strictly under
crates/fs/, 0 Protected Files):crates/fs/src/root_lock.rs: Process-wide canonical-pathtokio::sync::RwLockregistry with dead-weak pruning plus fail-closed OS advisory locking (std::fs::File::try_lock/try_lock_shared) on<canonical-root>/.version-lock(rejecting symlinks/non-files with400 InvalidRequestand validating Unix(dev, ino)), uncontended fast path, boundedDuration-budgetspawn_blockingretry withCancelAcquireOnDrop,RootVersionGuard::run_blockingretaining both locks across critical FS mutations if the async caller drops, andlock_shared()forCreateMultipartUpload(crates/fs/src/lib.rs) so concurrent initiations overlap while strictly excludingCreateBucket/DeleteBucketand version mutations.crates/fs/src/versioning/null_recovery.rs&crates/fs/src/versioning/publish.rs: Durablesupersedes-nullintent staged inside.tmp-*before atomic rename;staging::create_and_write_fileflush-before-rename onBODY_FILE,TAGS_FILE, andRECORD_FILE;commit_staged_versionrenaming atomically, markingCompletionTombstoneGuard::mark_published()immediately, recheckinglock_record::ensure_deletable, and retiring supersedednulldirectories and legacy plain files;reconcile_null_records_for_keyandreconcile_all_null_recordsdeterministically reconciling duplicate-nullkeys and single-nullsupersedes-nullintents while failing closed on equal sequences, active protection (403 AccessDenied), symlinks (400 InvalidRequest), or removal failure (500 InternalError); andexplicit_for_keyselecting the highest-sequence record via.max_by_key(|r| r.sequence).crates/fs/src/completion.rs,completion_replay.rs,lifecycle.rs,versioning.rs,reads.rs,buckets.rs,tagging.rs,acl.rs,version_listing.rs,README.md,MAP.md: Single-owner shared-root lock across multipart completion (upload -> .complete-* -> publish_object_if_locked -> tombstone teardown), best-effort stagedcompletionreceipt written before rename,.version-lockregular-file skip + symlink/dir fail-closed inlifecycle_buckets(), and updated coordination/crash-boundary documentation.crates/fs/src/versioning/shared_root_tests.rs,crates/fs/tests/crud/shared_root.rs,null_recovery.rs,root_lock.rs): 18 negative + 2 positive unit and real cross-processcurrent_exe()controls covering shared-root mutex/OS lock exclusion, shared/exclusive two-directional OS locking, symlink/dir fail-closed, queued & started cancellation safety, single- and duplicate-nullrecovery without resurrection, post-rename multipart receipt & tombstone durability, and preserved Object Lock501refusals.Closes #1537
Verification
Mutation Proofs (all intentionally broken, confirmed RED, and restored)
try_lockincrates/fs/src/root_lock.rs-> cross-processshared_rootcontrols andn_started_blocking_mutation_retains_os_lock_until_completion_after_future_dropfailed RED.RootVersionLock::for_canonical_root-> same-process canonical/symlink alias lock-sharing tests failed RED.symlink_metadatacheck inopen_safe_lock_file->n_malformed_version_lock_symlink_and_directory_fail_closedfailed RED.reconcile_null_records_for_keywhile keepingexplicit_for_keymax-sequence sorting -> duplicate-nullreconciliation and non-resurrection tests failed RED..tmp-*skip inversion_records-> staging visibility / cancellation controls failed RED.write_staged_completion_receiptinstage_version-> post-rename multipart replay test failed RED.tombstone_guard.mark_published()past superseded-null cleanup incommit_staged_version-> post-rename upload non-resurrection test failed RED.|| has_supersedes_null_intent(&record.path)?inreconcile_all_null_records->n_listing_reconciles_single_null_supersedes_intent_and_refuses_symlink_intentfailed RED (listing reconciliation must remove superseded legacy plain file).lock_sharedto exclusivelock()(concurrent shared lock failed RED) and bypassed OStry_lock_sharedinLockMode::Shared(shared lock must fail closed while an external OS exclusive lock is heldfailed RED).Role Verdicts
crates/fs/src/root_lock.rs), duplicate-null recovery (versioning/null_recovery.rs), staged publish/commit (versioning/publish.rs), and multipart replay (completion.rs,completion_replay.rs) — no break found.version-lockexclusion, shared/exclusive lock ordering, queued and started cancellation safety,create_and_write_fileflush-before-rename, and single/duplicate-null recovery without resurrection — no break foundBreaking Change
Checklist
cargo xtask verify)went red. The PR description names which ones
BREAKINGand a migration pathunsafeintroducedinventory/linkmeintroduced#[non_exhaustive]added to a DTO