Database Kernel (5): Transactions, Timestamps and GC

Multiple versions make concurrent reads and writes possible, but versions aren’t free: who creates them, who can see them, and when they can be dropped all need explicit answers. Part five of the plan series. 1. TxnMgr holds very little TxnMgr{ currentStartTs uint64 // starts at 2, +1 per txn, < 2^62 currentTxnId uint64 // starts at 2^62, +1 per txn lowestActiveId uint64 lowestActiveStart uint64 activeTxns []Txn // created, not committed/rolled back committedTxns []Txn // committed, not GC'd oldTxns []Txn // GC-able, not GC'd } The two counters start in different ranges so timestamps and transaction ids never collide: ...

October 22, 2026 · 2 min · daviszhen

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. ...

October 20, 2026 · 4 min · daviszhen