Module 5 · Dive 5.3
Checkout & GC.
Each LSN named a root, so opening the Volume at any LSN is just picking that root — checkout-at-LSN, the move behind the change feed and replica catch-up. But kept versions accumulate, so a retention policy reclaims old roots. The one rule garbage collection must obey: never reclaim a version a reader still pins. Scrub to a version, pin one, then run GC.
Open any LSN; keep what’s pinned
interactiveWhy GC follows the pins
graft.design.mdCheckout is free for the reason Dive 5.1 gave: the root and its nodes are still in the pool. Retention is the counterweight — without it the diffs pile up forever — so GC reclaims nodes that no retained or pinned version can reach, the on-disk job compaction (Dive 4.3) actually performs. The safety rule is the whole point: a reader pinned at an old LSN keeps that root and everything it reaches alive, so GC computes liveness from the active pins plus the retention window, never from age alone. Reclaim a pinned version and a reader would fault on a missing page; respect the pins and time travel stays sound. This is the machinery the change feed and replica catch-up sit directly on top of — and where Chapter III picks up, with the engines that turn these roots into replicated pages.
References & sources
- External
- orbitinghail/graftcheckout-at-LSN, the change feed
- CubDB.Snapshotpinned snapshots and release
- Reachability & GCliveness from roots, not age
- Echo records
- graft.design.mdcheckout-at-LSN, retention, the change feed
- store.design.mdsnapshot retention and GC on CubDB