SQLite

View Ticket
Login
Ticket Hash: fc62af45239916f7605ba07401b6f975d671bbdc
Title: Executing "PRAGMA journal_mode" may delete journal file while it is in use.
Status: Fixed Type: Code_Defect
Severity: Critical Priority: Immediate
Subsystem: Pager Resolution: Fixed
Last Modified: 2011-10-13 13:19:41
Version Found In: No released versions.
Description:
If "PRAGMA journal_mode" is used to change a connection from TRUNCATE or PERSIST mode to WAL, MEMORY, OFF or DELETE mode, the journal file is deleted. Even if it is currently being used by another connection (possibly in another process).

On unix, if that other connection (possibly in another process) is executing a write transaction when this happens, and the process exits unexpectedly for some reason, there will be no hot-journal file left in the file-system. If the connection had begun writing to the database file before the unexpected exit, the database may be left in a corrupt state.


dan added on 2010-06-17 09:52:50:
Introduced in commit [b78e58ae15] on 2010-03-19 15:48:14.


dan added on 2010-06-17 10:44:33:
The fix checked in for this ([1ec74591a9]) is sub-optimal in the sense that if a writer changes from "PRAGMA journal_mode=PERSIST" to "PRAGMA journal_mode=MEMORY", the journal file will never be removed from the file-system. It is not hot (as the first part of it is zeroed), but SQLite will be forced to open and close the file at the start of every read or write transaction to verify this.