page5
Database
file
SQLite Database
handle 1
Journal
File
2. User issues SQL commands via the database handle. SQLite determines the database pages to modify as a result of these commands. Before modifying the page in the cache, the original page content is journaled.
1. User issues SQL commands to begin a transaction. This causes the journal file to be created and the database file locked with a reserved lock.
3. When the transaction is to be committed, the journal file is synced to persistent storage, to ensure that the journal data is not corrupted if a system failure occurs.
4. After the journal file is synced, an exclusive lock is obtained on the database file, its content updated and the journal file deleted. Once the journal file is deleted, the transaction is irrevocably committed and can no longer be rolled back.
write_transaction.gif