APAaryan Patel

case study · systems · C++17 · zero runtime dependencies

raft-mvcc

A deterministic laboratory for the two correctness boundaries inside a distributed database: Raft consensus and multi-version concurrency control.

assertions across seeded faults, in 13 targeted and randomized tests
598
logical ticks for a five-node failover after isolating the leader
11
MVCC point reads per second across 10,000 retained versions
10.3M
sockets, fsyncs or snapshots in the simulator. Listed as missing, not implied
0
real engine · C++17 compiled to WebAssembly

Break the cluster. Inspect the proof.

These controls call the actual raft-mvcc sources, compiled with Emscripten. Every node state, term, log entry and invariant below comes from the engine. Logical ticks are deterministic simulator steps, not milliseconds.

loading the engine…tick 0000 dropped0 ops

how it works

Proposal acceptance is not commit evidence.

The minority leader may append locally, but only a current-term entry replicated to a majority can advance the commit index. The console above shows exactly that: isolate the leader, propose, and the new entry sits outlined in amber, appended but never committed, until a heal repairs it away.

Deterministic transport

The cluster is an in-process transport that can isolate a node, partition, drop messages, heal and drive logical time. Because delivery is deterministic, every failure replays exactly, without sleeping or hoping a race appears.

Serializable OCC on MVCC chains

Each key owns an ordered chain of immutable versions. A transaction commits only if its commit timestamp is later than its read timestamp and every read or written key still has exactly the version it observed. That is stricter than snapshot isolation, so lost updates and read/write anomalies abort.

An offline linearizability checker

It partitions a history by key, enforces real-time precedence, explores legal register states with memoization, and returns a witness when one exists. The oracle buttons above run it on a valid overlapping-write history and on a stale read.

measured · Apple M2 Pro, Apple Clang 17
Median of five, in-process simulator
experimentresult
3-node replicated writes~0.69M ops/s
5-node replicated writes~0.35M ops/s
MVCC point reads~10.3M reads/s
5-node failover11 logical ticks
correctness suite598 assertions
Safety invariants and where they're enforced
invariantenforcement
election safetyone vote per term, majority quorum
log matchingmatching prev index and term
commit safetycurrent-term entry on a majority
minority safetyisolated leader can't advance commit
OCC serializabilityany version change aborts
GC safetykeeps the anchor at the safe point
where it stops holding

A protocol laboratory, not a production database.

  • No network or diskThe throughput excludes sockets, serialization, fsync and scheduler overhead. These are simulator numbers; the useful comparison is 3 nodes against 5.
  • No snapshots or membership changesLog compaction, joint consensus and adding or removing nodes are listed as missing instead of being implied.
  • Single range onlyTransactions are atomic within one replicated range. Cross-range transactions would need a commit protocol this does not implement.
  • Ticks are not time"11 ticks to failover" is deterministic simulator steps. Wall-clock election timing on a real network is a different measurement.
reproduce
git clone https://github.com/asp53826/raft-mvcc
cd raft-mvcc
make test       # 598 assertions
make benchmark  # the table above
make sanitize