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
Software Engineering Fundamentals
Software Engineer
Meta
November 29, 2026
Software Engineer
Onsite
Software Engineering Fundamentals
Hard

0

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
MVCC
snapshot isolation
write-write conflicts
garbage collection
write skew
transactions
How to Approach This
  1. Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
  2. Choose data structures based on access patterns, not familiarity.
  3. Prefer immutable data and message passing over shared mutable state for concurrency.
  4. 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 Problems
Sample Answer
Requirements
  • begin() returns a transaction with a snapshot timestamp equal to the last committed timestamp.
  • get, put, delete inside 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...


Submit Your Answer
Markdown supported