tekartik / sqflite

SQLite flutter plugin
BSD 2-Clause "Simplified" License
2.87k stars 522 forks source link

Unhandled Exception: SqliteException(5): while executing statement, database is locked, database is locked #998

Open isaanyoha opened 1 year ago

isaanyoha commented 1 year ago

Hi @alextekartik, thanks for this package!

Sorry, I am making this complain here too as I encountered the issue on sqflite before saying try sqlite3 by simolus3, on the next day

Please kindly assist me here,

Why do I always get this issue 'Unhandled Exception: SqliteException(5): while executing statement, database is locked, database is locked (code 5)...'.

This lock locks forever whenever it occurs. How do I fix this? My app requires concurrrency as it is a multiplayer game app. I am using:

ezgif-3-774f9ss1e5sss5c2

------DETAIL BELOW------ Initially, I had the issue on sqflite package and I thought it was about not using .dispose() so I rewrote the database side of the app to use sqlite3 and then use the prepare() & .dispose() functions for every single database call, yet it still happens. Please what should I do?

Again, long before now, the first version the app was written with native Android (Android Studio) and it used sqlite too and I did not have this issue on the code. But after I rewrote the app's new version on flutter, (using the same code pattern, alogrithm) and started to use the sqflite, and later sqlite3 the issue happens and the app database function stops and app game play stalls consequently.

I will be glad if I can get a solution to this.

Thank you!

isaanyoha commented 1 year ago

Also, I added PRAGMA journal_mode=WAL; PRAGMA busy_timeout=5000;

ezgif-3-774fllll9ss1e5sss5c2