Skip to main content
Multi-Version Concurrency Control (MVCC) enables snapshot isolation and time-travel queries in HexxlaDB. Multiple versions of data coexist, with visibility scoped by commit sequence numbers.

Overview

MVCC in HexxlaDB provides:
  • Snapshot isolation — Readers see a consistent snapshot without blocking writers
  • Time-travel queries — Query the database as it was at any point in time
  • Audit trails — Full history of changes with changelog integration
  • Non-blocking reads — Read transactions never block write transactions

Enabling MVCC

MVCC is enabled via options:
When enabled, the database uses format v2 with MVCC-specific key encoding.

Physical key encoding

With MVCC enabled, version suffixes are appended to physical B+ tree keys:
Multiple committed versions coexist, with visibility scoped by commit_seq.

Timeline keys

Timeline keys map wall-clock time to commit sequence numbers:
These enable ViewAtTime queries by translating wall-clock timestamps to snapshots.

Snapshot transactions

View (current snapshot)

ViewAt (by commit sequence)

ViewAtTime (by wall-clock time)

Write transactions

Write transactions create new versions:

Version visibility

Readers see versions based on their snapshot:
  • View: Latest committed snapshot
  • ViewAt: State as of specific commit sequence
  • ViewAtTime: State as of specific wall-clock time
Older versions remain in the database until pruned.

Snapshot diff

Compare two snapshots to see what changed:

Retention and pruning

Configure MVCC retention:
Prune old versions:

MVCC statistics

Query MVCC stats:

Validity windows

MVCC snapshots are orthogonal to validity windows on records:
  • MVCC: Engine-time snapshot isolation (what the database knew at commit time)
  • Validity: Real-world time range (when the fact was true)
Both can be combined for powerful temporal queries.

Changelog integration

MVCC works with the logical changefeed for audit trails:

Performance considerations

  • Read performance: Unaffected by MVCC (snapshot reads are fast)
  • Write performance: Slight overhead for version tracking
  • Storage: Additional space for old versions (mitigated by retention and pruning)
  • Compaction: Essential for reclaiming space from old versions

Use cases

Audit trails

Track exactly what the database knew at any point:

Debugging

Reproduce issues by querying the database state at the time of the error:

Time-travel queries

Explore how data evolved over time:

See also