Disks Lie: Building a WAL that actually survives
3 points by emschwartz
3 points by emschwartz
SQLite doesn't follow the two-WALs or direct-write recommendations and is still a highly reliable database.
In a database, writes don’t have to be durable until the point that a transaction is committed. If the db crashes or power is lost before a commit, any writes in that partial commit must be ignored when the db recovers. So all it has to do is scan the WAL up through the last committed entry.
It’s the commit that's important: that's when all the writes have to be flushed safely.
I think double-WAL is to guard against the failure that SQLite excludes from its threat model: if your storage drive claims to write data but changes it in the process. There are indeed limits on what you can do with a single drive in that situation…
SQLite on a RAID?
SQLite on a checksummed RAID1 approaches double-WAL strategy, and I approve of this way of keeping proper layering.