-
-
Notifications
You must be signed in to change notification settings - Fork 813
Description
We currently use the default isolation level for both read and write connections.
https://kerkour.com/sqlite-for-servers#use-immediate-transactions says:
This one may be one of the biggest footguns of SQLite.
By default, SQLite starts transactions in
DEFERREDmode: they are considered read only. They are upgraded to a write transaction that requires a database lock in-flight, when query containing a write/update/delete statement is issued.The problem is that by upgrading a transaction after it has started, SQLite will immediately return a
SQLITE_BUSYerror without respecting thebusy_timeoutpreviously mentioned, if the database is already locked by another connection.This is why you should start your transactions with
BEGIN IMMEDIATEinstead of onlyBEGIN. If the database is locked when the transaction starts, SQLite will respectbusy_timeout.
Hardest part is proving this issue one way or the other.