drift
drift copied to clipboard
Warning database has been locked for 0:00:10.000000. Make sure you always use the transaction object for database operations during a transaction
Can you post a snippet that reproduces this behavior?
I get this as well, not locally, but with the automated tests inside play.google.com. I've got a bit more info, but no simple snippet for reproduction. I'm using moor 4.4.0
SqfliteDatabaseException: DatabaseException(error database_closed)
File "database_mixin.dart", line 288, in SqfliteDatabaseMixin.checkNotClosed
File "database_mixin.dart", line 123, in SqfliteDatabaseExecutorMixin._rawQuery
File "database_mixin.dart", line 118, in SqfliteDatabaseExecutorMixin.rawQuery
File "encrypted_moor.dart", line 149, in _SqfliteExecutor.runSelect
File "engines.dart", line 72, in _BaseExecutor.runSelect.<fn>
File "engines.dart", line 52, in _BaseExecutor._synchronized.<fn>
File "synchronized.dart", line 18, in Lock.synchronized.callBlockAndComplete
File "synchronized.dart", line 16, in Lock.synchronized.callBlockAndComplete
File "synchronized.dart", line 27, in Lock.synchronized
File "engines.dart", line 50, in _BaseExecutor._synchronized
File "engines.dart", line 69, in _BaseExecutor.runSelect
File "select_with_join.dart", line 210, in JoinedSelectStatement._getRaw.<fn>
File "select_with_join.dart", line 208, in JoinedSelectStatement._getRaw.<fn>
File "connection_user.dart", line 154, in DatabaseConnectionUser.doWhenOpened.<fn>
File "zone.dart", line 1362, in _rootRunUnary
Device: Nokia 1 Android: 8.1.0
Maybe this pops up on slow devices or something?
I can't be sure for certain, as I changed some stuff in my app, but when using moor: ^4.2.1 this did not happen. And maybe the automated tests of google didn't include the Nokia back then!
I'll try to research this a bit more myself first.
Thanks for the additional information! Judging from the error code, it looks like the database is somehow getting used after being closed. I'm not yet sure how that could have happened, moor is supposed to guard against this.
Thanks for the additional information! Judging from the error code, it looks like the database is somehow getting used after being closed. I'm not yet sure how that could have happened, moor is supposed to guard against this.
I’ll provide more information tomorrow, if I can find anything useful.
The problem for me seems a combination of deleting/creating databases (I'm using encryption and the user should be able to login/logout and create a new db + password every time). On the "Nokia" database initialisation takes 30 seconds (one time it took 90 seconds...). In combination with state management this turned into some troubles...
For now I've manually added an await db.doWhenOpened((_) => null); before closing & deleting a database and after re-initialising a new db instance. That fixed the problems for me it seems...