Hacker News new | ask | show | jobs
by andix 892 days ago
There are cases where the wal file is not merged on shutdown of the application. I think a corrupted database can also prevent merging the wal file automatically. A corrupted database can often be repaired, but it needs to be done manually.

I've been bitten badly by that issue once. I just mounted the .db file into a docker container and didn't realize that sqlite creates wal files. On an non-graceful shutdown of the application the wal file was not merged into the db and the container deleted. And around a day of changes were lost.

Conclusion: Sqlite databases should be placed into their own folder, so it's obvious that it's not always just one file.

1 comments

This is configurable, and for small things you might disable WAL completely.

When using WAL, if you’re copying or backing up the database it’s possible to force a checkpoint, then you can copy the .db file alone knowing exactly up to when it contains data.

I had to learn all that the hard way ;)