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