Snapshot Isolation Reads Over a Multi-Version Key-Value Store
Last updated: November 29, 2026
Quick Overview
Build a small in-memory MVCC key-value store: each transaction reads a consistent snapshot, sees its own writes, and commits with first-committer-wins conflict detection. Include garbage collection of versions no snapshot can see.
Meta
November 29, 20260
0
0 solved
Build a small in-memory MVCC key-value store: each transaction reads a consistent snapshot, sees its own writes, and commits with first-committer-wins conflict detection. Include garbage collection of versions no snapshot can see.
Meta runs MySQL with InnoDB (an MVCC engine) underneath much of its storage, and RocksDB-based systems use sequence-number snapshots in a similar way. Asking a candidate to build snapshot isolation from scratch shows whether they actually understand what the isolation level guarantees, how conflicts are detected, and what anomalies like write skew it still allows.
What the Interviewer Expects
- Stores a list of (commit_ts, value) versions per key and reads the newest at or before the snapshot
- Buffers writes in the transaction and supports read-your-writes and deletes via tombstones
- Detects write-write conflicts at commit using first-committer-wins
- Assigns commit timestamps atomically with installing versions
- Garbage collects versions below the oldest active snapshot while keeping the one it can see
- Explains write skew and how serializable snapshot isolation or locking prevents it
Key Topics to Cover
How to Approach This
- Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
- Choose data structures based on access patterns, not familiarity.
- Prefer immutable data and message passing over shared mutable state for concurrency.
- Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
- Give a concrete write skew example in a Meta product and how you would prevent it.
- How would you distribute timestamp assignment across shards?
- What happens to GC if a long-running analytics transaction never finishes?
- How would you add range scans that respect snapshots?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
begin()returns a transaction with a snapshot timestamp equal to the last committed timestamp.get,put,deleteinside the transaction; reads never see changes committed after the snapshot...
High-Level Design
Each key maps to a sorted list of (commit_ts, value). A read binary-searches for the last version with commit_ts <= snapshot, so readers never block writers or each other.
Writes go into the tran...