What exactly causes the database to lock up ("Warning database has been locked...") on a lower level? #1030
Replies: 1 comment 1 reply
-
This is a pure opiniated warning. All calls are serialized (this could change in the future). If a pending call waits for more than 10 seconds, this is printed. You can remove the warning by calling something like: setLockWarningInfo(callback: () {}); If you have extensive calls, this could be normal and you might decide to remove the warning. If you have a deadlock (typically when using wrongly the database object in a transaction instead of the transaction itself), this helps warning you. Otherwise you might want to look whether you have unoptimized calls or transaction that last too longs).
Here is an example of what the message means: await database.transaction((txn) async {
// Ok
await txn.execute('CREATE TABLE Test1 (id INTEGER PRIMARY KEY)');
// DON'T use the database object in a transaction
// this will deadlock!
await database.execute('CREATE TABLE Test2 (id INTEGER PRIMARY KEY)');
}); See here |
Beta Was this translation helpful? Give feedback.
-
Ive been having this lock up issue (Warning database has been locked for 0:00:10.000000. Make sure you always use the transaction object for database operations during a transaction), and none of the solutions Ive found have been able to fix it. Because of that, I'm starting to think my app itself may be causing the lock up through some indirect way, such as perhaps some sort of memory leak. So for anyone that may know, can you please explain what are the exact conditions that eventually cause the database to lock up forever?
Beta Was this translation helpful? Give feedback.
All reactions