Skip to content

feat: add rc and rr transaction isolation#319

Merged
KKould merged 3 commits intomainfrom
feat/transaction-isolation-levels
Apr 16, 2026
Merged

feat: add rc and rr transaction isolation#319
KKould merged 3 commits intomainfrom
feat/transaction-isolation-levels

Conversation

@KKould
Copy link
Copy Markdown
Member

@KKould KKould commented Apr 16, 2026

What problem does this PR solve?

KiteSQL did not expose configurable transaction isolation levels through DataBaseBuilder, and ordinary reads in RocksDB-backed transactions were not pinned to a stable statement-level or transaction-level snapshot.

That made it impossible to provide an explicit ReadCommitted / RepeatableRead contract at the database API layer, and it also left storage capabilities implicit instead of validated by the selected backend.

Issue link:

What is changed and how it works?

  • Add TransactionIsolationLevel::{ReadCommitted, RepeatableRead} and plumb the selected level through DataBaseBuilder, Database, and storage transaction creation.
  • Extend the storage abstraction with transaction_with_isolation, default_transaction_isolation, and validate_transaction_isolation so isolation semantics stay separate from storage-specific capabilities.
  • Add statement-scope transaction hooks and use them to manage read snapshot lifetime during SQL execution.
  • Implement RocksDB and optimistic RocksDB read visibility with explicit snapshots attached to ReadOptions:
    • ReadCommitted creates a fresh snapshot per statement.
    • RepeatableRead keeps one fixed snapshot for the whole transaction.
  • Keep reads flowing through the underlying storage transaction object so transactions still observe their own writes.
  • Declare LMDB support as RepeatableRead only and memory support as ReadCommitted only, with builder-time validation for unsupported level requests.
  • Add user-facing transaction isolation documentation, expose it through crate docs, and link it from the README / feature docs.

Code changes

  • Has Rust code change
  • Has CI related scripts change

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Note for reviewer

The main review surface is:

  1. DatabaseBuilder / Database plumbing for isolation-level selection and storage capability validation
  2. RocksDB statement-scoped vs transaction-scoped snapshot handling for ReadCommitted and RepeatableRead
  3. the transaction isolation support matrix and documentation entrypoints

Validation used for this branch:

  • cargo check --lib
  • cargo test --lib
  • cargo test test_lmdb_rejects_read_committed_isolation --lib --features lmdb

@KKould KKould self-assigned this Apr 16, 2026
@KKould KKould added the enhancement New feature or request label Apr 16, 2026
@KKould KKould merged commit 0da0626 into main Apr 16, 2026
14 checks passed
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