Make IndexedMap publication transactional - #60
Merged
Conversation
forhappy
marked this pull request as ready for review
August 2, 2026 23:18
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
TransactionalStoresupport behind the soleengine.indexed_map(...)constructorapply_ifexpectations inside every publication retry so a superseded conditional write cannot publishFileNodeStoremanifest reads and writes across independently opened handles and processes with an OS file lockRoot cause
The IndexedMap store abstraction previously required only
Store + ManifestStore, so the coordinator published its canonical state with a direct root CAS even when the engine exposed strict multi-key transactions. In addition,apply_ifchecked its expected source version before calling the unconditional retrying mutation path. A concurrent writer could supersede that version between the check and publication, turning the conditional operation into a successful write.FileNodeStorealso coordinated manifests only with a mutex shared by cloned handles. Independently opened handles or separate processes could race root transactions.Correctness model
Source data, secondary indexes, snapshot metadata, descriptors, retention, and pins remain immutable content-addressed objects selected by one canonical collection root. Candidate nodes may be written before commit, but they are unreachable. The strict transaction validates the previously loaded canonical root and advances that one root as the only visibility transition. Readers therefore observe the complete old state or complete new state. Conflicts retry from a fresh state; unreachable candidate nodes are safe for quiescent GC.
Keeping immutable node publication outside the transaction and committing one root preserves a constant-size transactional visibility boundary while supporting arbitrarily large source/index updates.
Impact
Existing callers continue to use only
engine.indexed_map(...). Backends without strict transactions now fail closed withUnsupportedTransactions. Backends claiming support must provide linearizable root validation and atomic publication across all handles/processes sharing the store.Validation
cargo test— 500 unit tests, all integration tests, and 74 doc tests passedcargo clippy --all-targets -- -D warningsRUSTDOCFLAGS='-D warnings' cargo doc --no-deps./scripts/check-secondary-index-cutover.shapply_ifraceFileNodeStorehandle race