Skip to content

feat: implement SSI predicate locking#10

Merged
danpasecinic merged 13 commits intodevelopmentfrom
feat/implement-ssi-predicate-locking
Jan 16, 2026
Merged

feat: implement SSI predicate locking#10
danpasecinic merged 13 commits intodevelopmentfrom
feat/implement-ssi-predicate-locking

Conversation

@danpasecinic
Copy link
Owner

@danpasecinic danpasecinic commented Jan 16, 2026

This pull request introduces Serializable Snapshot Isolation (SSI) to the MVCC engine, enabling true serializable transactions and improving transaction isolation guarantees. It adds a new SSI manager, updates transaction logic to support various serializable modes, and introduces comprehensive error handling and testing for serializability conflicts.

Serializable Snapshot Isolation (SSI) Integration:

  • Added the SSIManager and related types to the MVCC engine (MvccEngine), with new logic for tracking reads and writes, validating serializability at commit, and handling aborts and cleanup. (crates/crabstash-txn/src/mvcc.rs, crates/crabstash-lock/src/lib.rs) [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]

  • Extended the IsolationLevel enum to support SerializableReadOnly and SerializableDeferrable modes, with helper methods for checking isolation properties. (crates/crabstash-txn/src/transaction.rs)

Error Handling Improvements:

  • Added new error variants for serializability violations (WriteSkew, PhantomRead, SerializableConflict) and mapped SSI conflict errors to these variants. (crates/crabstash-common/src/error.rs, crates/crabstash-txn/src/mvcc.rs) [1] [2] [3]

Testing and Validation:

  • Introduced comprehensive tests for serializable isolation, including detection of write skew, phantom reads, and proper cleanup of SSI state on abort. (crates/crabstash-txn/src/mvcc.rs)

Dependency and API Updates:

  • Added rapidhash as a dependency for workspace crates, likely used by the SSI manager. (Cargo.toml, crates/crabstash-lock/Cargo.toml) [1] [2]
  • Updated the API to pass the new isolation levels through the public interface, simplifying how isolation is handled in the top-level Db type. (crates/crabstash/src/lib.rs) [1] [2]

Development Tooling:

  • Added tempfile as a dev-dependency to facilitate testing. (crates/crabstash-txn/Cargo.toml)

@danpasecinic danpasecinic self-assigned this Jan 16, 2026
@danpasecinic danpasecinic added the enhancement New feature or request label Jan 16, 2026
@danpasecinic danpasecinic merged commit 6153256 into development Jan 16, 2026
25 of 30 checks passed
@danpasecinic danpasecinic deleted the feat/implement-ssi-predicate-locking branch January 16, 2026 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant