realm / realm-dart

Realm is a mobile database: a replacement for SQLite & ORMs.
Apache License 2.0
758 stars 86 forks source link

Durability not consistent. Error code: 1007. #1727

Closed htetlynnhtun closed 2 months ago

htetlynnhtun commented 3 months ago

What happened?

I have 1 unit test and 1 integration test using Realm instance. InMemory config for unit test and Local config for integration test. Tests are passing if both of them run one by one. Tests started to fail if both of them run concurrently with error Durability not consistent. Error code: 1007.

Repro steps

https://github.com/htetlynnhtun/realm_test

Version

3.22.2

What Atlas Services are you using?

Local Database only

What type of application is this?

Flutter Application

Client OS and version

Mac 14.5

Code snippets

No response

Stacktrace of the exception/crash you're getting

Some unit test with in memory config (failed)
RealmException: Durability not consistent. Error code: 1007.
package:realm_dart/src/handles/native/error_handling.dart 59:9  _raiseLastError.<fn>
package:ffi/src/arena.dart 124:31                               using
package:realm_dart/src/handles/native/error_handling.dart 48:3  _raiseLastError
package:realm_dart/src/handles/native/error_handling.dart 16:7  PointerEx.raiseLastErrorIfNull
package:realm_dart/src/handles/native/realm_handle.dart 50:10   new RealmHandle.open
package:realm_dart/src/realm_class.dart 207:24                  Realm._openRealm
package:realm_dart/src/realm_class.dart 143:98                  new Realm._
package:realm_dart/src/realm_class.dart 141:38                  new Realm
test/realm_unit_test.dart 7:19                                  main.<fn>
::endgroup::

Relevant log output

No response

sync-by-unito[bot] commented 3 months ago

➤ PM Bot commented:

Jira ticket: RDART-1057

nirinchev commented 3 months ago

This likely means you're trying to open an in-memory realm at the same path as a persisted realm file. While the in-memory realm doesn't store data on disk, it still creates a file that is used for cross-process synchronization.

htetlynnhtun commented 3 months ago

This likely means you're trying to open an in-memory realm at the same path as a persisted realm file. While the in-memory realm doesn't store data on disk, it still creates a file that is used for cross-process synchronization.

For test using Configuration.local, I set a different realm file name as guided here. And delete realm instance after each test. The problem is gone. Thank you. But still someRandomName.realm.lock files are left. Any suggestion to clean up those files? And should I still override defaultRealmName for inMemory instances if I already override it for local instances?

nirinchev commented 2 months ago

The .lock file will not be deleted by Realm because it's what's used to synchronize access across processes and can't be safely removed. Since you know there's no other process accessing these files, you should be able to delete it yourself with no risk involved.