Implementing Git for Data on DuckDB (Part 4): Moving Metadata into Tables — Transactions, Crash Consistency and 'Hidden but Readable'
The first three posts were about features. This one is about the engineering of the metadata itself: where snapshots and branches are stored, and how they survive. 1. The problem: a metadata block is not transactional The first implementation wrote the reference registry (snapshots/branches/pins) into the checkpoint metadata block. It persisted, but had two fatal issues: Not in a transaction: if CREATE SNAPSHOT failed or rolled back, the block might already have been written; No WAL: if the process crashed before the next checkpoint, the change was gone. The actual requirement: reference changes must commit or roll back with the caller’s transaction, like ordinary data, and go through WAL replay. ...