Trouble with automatic WAL mode
Hello, as well known, since the latest version sqlite-net defaults to WAL mode for journal. Unfortunately, this has caused me a lot of trouble: I have an app that offers export data functionality and, until this change, I implemented it simply by copying the db file, confident that all the data was there. But this is no more true now that WAL is enabled: a lot of recently written data reside in the -WAL file and, trying to simply copy the db file often end with a corrupt file. Doing a checkpoint (PRAGMA wal_checkpoint(FULL)) before exporting at least put the db file in a consistent state, but still most recent data are often missing. Also, trying to close the connection does not help: the -WAL file is still there, retaining the most recent data. I am wondering if someone knows a better way to export data (that is, create a consistent copy of the database) with WAL enabled and if, in a future version, it will be possible to opt out from WAL mode at connection ctor level (trying to change journal_mode after the connection is open does not work consistently [in fact, almost never, and, even when it seems to work, it is soon reverted to WAL mysteriously]). Any help would be much appreciated.
I have made two changes (1.6-beta to be released soon) that help address this:
- I have made it possible to disable WAL mode if it's not a good fit (see the new
ConnectionsString) - I have added a
Backupfunction that will output a file using sqlite's own backup routines. This should give you the most up-to-date data.
Thank you Frank, I look forward to use these new features, especially the backup function, so I won't have to disable WAL if it works well.
You can try them out with 1.6-beta now. My tests are passing so I'm going to close this for now. Please let me know if it doesn't work for you.