*.mdb文件可以同时以两个线程打开吗?

发布于 2025-01-29 07:34:05 字数 822 浏览 4 评论 0原文

Android Object Box版本3.1.2
Flutter Object Box 1.4.1

Android代码确实读/写操作
仅会读取操作

有时,Android侧 。 无法更新TX(此线程上的另一个读取事务仍处于活动状态)(错误代码-30783)

当我仅使用Android时,永远不会发生这种例外。

Android:

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

颤抖:

    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);

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);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迟月 2025-02-05 07:34:05

拥有两个Libs似乎是一个棘手的设置...您确定您是否在DART中使用不同的线程(例如隔离)(或者在Android中)?因为错误“另一个读取事务仍然在此线程上处于活动状态”,就像使用同一线程一样读取。在这种情况下,每个LIB的某些线程 - 本地缓存将干扰另一个LIB。

因此,请确保永远不要在两个Libs上使用相同的线程。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文