I'm wondering about the recovery progress in SQLite (WAL mode). If system crash occurs, how SQLite knows 'I have to recovery using WAL file'? and what SQLite exactly do in recovery progress?
please help.
The documentation says:
The original content is preserved in the database file and the changes are appended into a separate WAL file. A COMMIT occurs when a special record indicating a commit is appended to the WAL.
[…]
When a reader needs a page of content, it first checks the WAL to see if that page appears there, and if so it pulls in the last copy of the page that occurs in the WAL […]. If no copy of the page exists in the WAL […], then the page is read from the original database file.
If a system crash occurs, the last commit record has not been written. Without the commit record, the new data is not considered valid, and the database simply ignores it.
So no actual recovery operation is needed. The database just continues to write new data beginning from the last valid commit record.