Question about WAL Checkpoint process
(1) By anonymous on 2021-09-25 07:43:34 [link] [source]
When SQLite start Checkpoint,is there a backup file create to avoid crash in between multi write into into main file?
for example if there need copy 1000 page into main file, what happy if app crashed at write 999 page?
If they are create backup file and rename it late for atomic, this will cause a lot IO for a huge database(for example 1TB database). Is this the case for SQLite?
I know there is batch-atomic-write to solve this problem, but that only work for F2FS.
(2) By anonymous on 2021-09-25 11:45:02 in reply to 1 [link] [source]
The WAL file is the backup. When a page is successfully checkpointed the database is updated to reflect this. If page 1000 was not written successfully, clients continue to read it from the WAL file as if the checkpoint of that page never even started.
(3) By anonymous on 2021-09-25 11:46:54 in reply to 1 [source]
The checkpoint operation does not create a backup of the database, the pages being copied into the main file will not be marked as checkpointed in the WAL until after the copy is successful (here's your atomic commit). If the copy process breaks for any then the pages written are ignored (as they still show up as uncheckpointed in the WAL) and can be recovered from the WAL later