SQLite and database is locked error

Yes, I have explored WAL. The core issue that requires BEGIN IMMEDIATE to resolve is present both with WAL and without WAL.

WAL itself does help with avoiding database locks because it unblocks reads while writes are in progress. Without WAL, writes block both reads and other writes. Because of this, I think for the majority of Django users WAL mode is a better default as it allows higher concurrency. At some point I’d like to also explore how Django could enable WAL mode by default (e.g. when creating a new SQLite database), but I think addressing the errors in transactions is more important so I haven’t brought it up until now. As I side note I did open a PR on Simon’s benchmark repository showing the db lock issue that we are discussing here.