This one is a note about SQLite in WAL mode, and about a recovery path I wrote for a small on-device store in an iOS app I'm working on, which looked fine in review and still managed to lose a committed transaction in a test.
The setup
The app keeps a few settings in a SQLite database opened through GRDB , in WAL mode, which means that on disk the database is three files and not one:
store/ store.sqlite # the database itself store.sqlite-wal # committed transactions not yet copied into the database store.sqlite-shm # shared-memory index for the WAL
Enter fullscreen mode
Exit fullscreen mode
When the app opens the store and finds something it can't trust (it was written by a different install, or it's corrupt), it doesn't delete anything.…