What I learned building a crash-safe WAL in Go (CRC, mmap, fsync, torn writes)
unisondb.ioΒ·1dΒ·
Discuss: r/golang
πŸ“Database WAL
Preview
Report Post

Learn how to build a crash-safe Write-Ahead Log (WAL) in Go, and why CRC32 alone is not enough. We explore the durability layers UnisonDB uses to prevent corruption after crashes.

Diagram of UnisonDB’s corruption-proof WAL path

The Problem#

Every database promises durability. Write your data, get an acknowledgment, sleep well. But what happens between the write() syscall (or a memory-mapped store) and the moment electrons finally settle on persistent media?

There is a long, leaky pipeline β€” and every layer can betray you. A lot can go wrong:

  1. Power failure mid-write β€” The system crashes while writing, so only part of your data reaches disk.
  2. **Bit fli…

Similar Posts

Loading similar posts...