-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Realm is closed but deleteRealm() errors out #1783
Comments
➤ PM Bot commented: Jira ticket: RDART-1090 |
The closed property refers to that particular instance and doesn't take into account other components or processes that might be using the realm file at that time. As it was likely the case in the other issue you found, the sync component might hold on to the realm file for a while and prevent you from immediately deleting it. You can either stop the sync session or retry the deletion with some backoff. |
How can I stop the sync session in Dart? |
|
this ProxyService.cron.isolateKill();
final path = realm!.config.path;
// You must close a realm before deleting it
if (realm != null) {
realm!.syncSession.pause();
realm!.close();
}
// Delete the realm
Realm.deleteRealm(path); code is not working close is called but not closing the DB any suggestion? cc @nirinchev |
Same issue here with Local (non-sync) Realm version 20.0.0. Any idea about the workaround? |
What happened?
When calling deleteRealm() after ensuring that the realm is closed (by realm.isClosed), I still get a RealmException:
RealmException: Cannot delete files of an open Realm: '.../6634c5a3b297ab517bc46ad0/default.realm' is still in use.. Error code: 2012.
I just found this tangentially related issue which mentioned waiting or pausing the syncsession - I just wonder why the isClosed property is true then.
I am closing the realm the following way:
Repro steps
Version
3.22.3
What Atlas Services are you using?
Atlas Device Sync
What type of application is this?
Flutter Application
Client OS and version
Android 14
Code snippets
No response
Stacktrace of the exception/crash you're getting
No response
Relevant log output
The text was updated successfully, but these errors were encountered: