-
|
I'm trying to troubleshoot a database lock issue. One potential cause that I've identified is that when the app receives a notification while it's in the background or terminated, we call the same return LazyDatabase(() async {
final dbFolder = await AppDatabase.getDatabasesPath();
final password = await _getDatabasePassword(...);
return NativeDatabase.createInBackground(
dbFile,
isolateSetup: () async {
open.overrideFor(OperatingSystem.android, openCipherOnAndroid);
},
setup: (db) {
// Check that we're actually running with SQLCipher by querying the
// cipher_version pragma.
final result = db.select('pragma cipher_version');
if (result.isEmpty) throw UnsupportedError('SQLCipher unavailable');
db
..execute("pragma key = '$password'")
..execute('pragma busy_timeout = 1000')
// Tests that the key is correct by selecting from a table.
..execute('select count(*) from sqlite_master');
},
);
});We use FirebaseMessaging for notifications so the What's the best way to handle this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
With the busy timeout already there, I think the chance for locks shouldn't be that high. Do you know if FCM only starts a new isolate or launches an independent Flutter engine / isolate group? If it's in the same isolate group, you could potentially use the |
Beta Was this translation helpful? Give feedback.
With the busy timeout already there, I think the chance for locks shouldn't be that high.
Do you know if FCM only starts a new isolate or launches an independent Flutter engine / isolate group? If it's in the same isolate group, you could potentially use the
drift_flutterpackage with theshareAcrossIsolates: trueoption set to make drift share the connection across isolates.