Can the *.mdb file be open in two thread at the same time?

159 views Asked by At

Android Objectbox Version 3.1.2
Flutter Objectbox Version 1.4.1

Android code does read/write operation
Flutter code only does read operation

Sometimes the android side throws this exception:
Could not renew tx (another read transaction is still active on this thread) (error code -30783)

This exception never occurs when I use android only.

Android:

boxStore = MyObjectBox.builder().androidContext(application).build()

Flutter:

    final documentDir = await getApplicationDocumentsDirectory();
    var androidDir =
        '${documentDir.parent.absolute.path}/files/objectbox/objectbox/';
    var objectboxDir = Directory(androidDir);
    var exists = await objectboxDir.exists();
    if (!exists) {
      objectboxDir.create(recursive: true);
    }
    store = await openStore(directory: androidDir);
1

There are 1 answers

0
Markus Junginger On

Having the two libs seems like a tricky setup... Are you sure you are using distinct threads (e.g. isolates) in Dart (or alternatively, in Android)? Because the error "another read transaction is still active on this thread" reads rather like the same thread is used. In that case, some thread-local caching of each lib will interfere with the other lib.

Thus, make sure that never use the same thread on both libs.