Master the fundamental concepts of build a simple key-value store through this focused micro-challenge.
You have read the whole brief, and the concepts above stay free on every task. Writing and running the code needs a plan.
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
Every task includes starter code, theory, and hidden tests so you can implement and verify locally in the browser.
How it worksMulti-version concurrency control stores several values for one key tagged with sequence or timestamp. Readers observe a snapshot without blocking writers; writers append new versions. PostgreSQL heap tuples and RocksDB with column families use variants of this idea.
Map key to sorted list of (seq, value) pairs. Read picks latest version with seq <= read_snapshot.
cLoading…
min_active_snapshot for retention policyKeep the relevant documentation open while you implement. When your output disagrees with the reference, trace one failing case by hand before changing random lines.
You will implement simplified MVCC get/put with snapshot reads. This exercise requires a reader at snapshot S not to see writes committed after S.
Multi-version concurrency control keeps every committed version of a value, so a reader sees a consistent snapshot without blocking writers. Build an MVCC key-value store.
commit_ts.commit_ts <= ts. A reader never sees a write that committed after its snapshot. That is what prevents dirty and non-repeatable reads: a transaction that started at ts 3 keeps seeing the same value even after someone commits at ts 4.commit_ts <= ts. That version itself stays: the reader at ts still needs it. A key with no version at or before ts is left alone.At most 16 keys.
Commands until the end of input:
write K V TSread K TSchain Kgc TSwrite: write key=10 value=100 commit_ts=2, or write key=10 rejected: commit_ts 3 not after 4.read: read key=10 at ts=3 -> 100 (commit_ts=2), or read key=10 at ts=1 -> none.chain: key=10 chain: 200@4 -> 100@2, newest first as value@commit_ts, or key=10 chain: empty.gc: gc oldest_active_ts=3 removed=1.