Skip to content
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

Bad state: failed to create store: Cannot open store: another store #703

Open
centy opened this issue Dec 23, 2024 · 3 comments
Open

Bad state: failed to create store: Cannot open store: another store #703

centy opened this issue Dec 23, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@centy
Copy link

centy commented Dec 23, 2024

Build info

  • objectbox version:"4.0.3"
  • Flutter/Dart version: Flutter: 3.27.0 Dart SDK version: 3.6.0
  • Build OS: [Windows 10 ]

Steps to reproduce

Getting such callstack on Crashlitics.

Fatal Exception: io.flutter.plugins.firebase.crashlytics.FlutterError: Bad state: failed to create store: Cannot open store: another store is still open using the same path: "/data/data/com.gst.color.numbers.pixyfy/app_flutter/objectbox" (OBX_ERROR code 10001)
at ObjectBoxNativeError.throwMapped(helpers.dart:74)
at .throwLatestNativeError(helpers.dart:54)
at .checkObxPtr(helpers.dart:31)
at Store._checkStorePointer(store.dart:451)
at .new Store(store.dart:274)
at .openStore(objectbox.g.dart:271)
at PictureInfoRepository.performOpen(picture_info_repository.dart:164)

We are initializing DB in main functon.

Scerario look more less like this:

  1. User start app and it works
  2. App show ad
  3. Ad became closed and app is back again --> database is locked

I can not reproduce that, some additional conditions must occurs. This what we see in crashlitics

Expected behavior

Do not crash or some workaround

Actual behavior

App not starting

@centy centy added the bug Something isn't working label Dec 23, 2024
@greenrobot-team
Copy link
Member

greenrobot-team commented Jan 13, 2025

Thanks for reporting!

TL;DR: see #436 for a possible workaround.

A little background: the ObjectBox database runs on the process level. Only some state lives in the Dart VM, but otherwise calls are made to the native implementation.

Somehow it appears that the Dart state can be cleared (e.g. the Dart app terminates) without the native process ending, leaving the ObjectBox database open.

I wonder if using something like an AppLifecycleListener and then opening and closing the database when leaving or entering the detached state would solve this?

(internal issue objectbox-dart#67)

@greenrobot-team greenrobot-team self-assigned this Jan 13, 2025
@centy
Copy link
Author

centy commented Jan 20, 2025

I just wondering if it is possible to detect this case and attach to running instance?

@greenrobot-team
Copy link
Member

I've linked the issue with exactly that workaround:

TL;DR: see #436 for a possible workaround.

Here is the direct link: #436 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants