The binlog cache: memory, temp files and seven states

The previous post looked at the on-disk file. This one looks at what happens before: a transaction’s events go into the binlog cache and are written to the binlog as a unit at commit. The problem it solves A binlog transaction must be all-or-nothing: either every event lands in the file or none does. The cache is that staging area — small transactions stay in memory, large ones spill to a temporary file, and commit writes the whole thing at once. ...

November 28, 2026 · 4 min · daviszhen

MySQL binlog format: what is inside an 891-byte file

There is plenty of binlog documentation, but few people can name every byte. This post takes an 891-byte file from a minimal transaction and walks the event chain. Why the format matters Estimating how many bytes a transaction occupies when chasing replica lag; Writing parsers that skip events by reading only the header; Reading the source: whether log_pos means “start” or “end” changes how you reason about writes. Environment Stock MySQL 8.0.44, separate datadir, started with explicit flags: ...

November 28, 2026 · 4 min · daviszhen

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

October 20, 2026 · 3 min · daviszhen