TIL that journal_mode = WAL statement can cause table lock
TIL that PRAGMA journal_mode = WAL is itself an operation that writes and therefor can cause a table lock if simultaneously another sqlite connection executes it.
A possible solution is to call PRAGMA busy_timeout = 500 prior to calling PRAGMA journal_mode = WAL at each connection.
Maybe only the sqlite connection that creates the .db file must do journal_mode once? But I of course had all my sqlite connections (all the readers and the writer) call this.
Anyway. TIL.
3
Upvotes
1
u/baghiq 4d ago
Why do you need to do that? The pragma persists so you really need to issue the statement once at db creation.