Implementing Git for Data on DuckDB (Part 2): Pinning History — Snapshots, Retention Watermarks and AT SNAPSHOT
The previous post argued that the counterintuitive gate is retention. This one takes it apart: two watermarks, one measurement, and making AT (SNAPSHOT => 'name') actually read. 1. Two watermarks DuckDB’s MVCC only answers “can this transaction see that row.” Supporting snapshots means separating two questions: Watermark Computed from Used for LowestVisibilityBound() Active transactions only Deciding which commits are “past”: releasing locks, cleaning transaction records LowestRetentionBound() min(active transactions, pinned snapshots) Deciding which historical versions must not be reclaimed We initially only had the first. The result: create a snapshot, run a checkpoint, and the old version is reclaimed anyway — because to checkpoint, there are no active transactions, so the old version is garbage. ...