系统崩溃时Sqlite3如何以WAL模式恢复
How Sqlite3 recovery in WAL mode when system crash
我想知道 SQLite(WAL 模式)中的恢复进度。
如果系统崩溃,SQLite怎么知道'I have to recovery using WAL file'?
SQLite 在恢复过程中到底做了什么?
请帮忙。
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.
如果发生系统崩溃,最后的提交记录还没有写入。没有提交记录,新数据被认为是无效的,数据库将忽略它。
所以不需要实际的恢复操作。数据库只是继续从最后一个有效提交记录开始写入新数据。
我想知道 SQLite(WAL 模式)中的恢复进度。 如果系统崩溃,SQLite怎么知道'I have to recovery using WAL file'? SQLite 在恢复过程中到底做了什么?
请帮忙。
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.
如果发生系统崩溃,最后的提交记录还没有写入。没有提交记录,新数据被认为是无效的,数据库将忽略它。
所以不需要实际的恢复操作。数据库只是继续从最后一个有效提交记录开始写入新数据。