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 Realm file header (#3) #5063

Closed
AlexTip opened this issue Aug 3, 2017 · 13 comments
Closed

Bad Realm file header (#3) #5063

AlexTip opened this issue Aug 3, 2017 · 13 comments

Comments

@AlexTip
Copy link

AlexTip commented Aug 3, 2017

Hi there! We've got growing Realm exception (kinda about 17k crashes from about 800 users for the last 30 days) with the next stack trace:

Fatal Exception: io.realm.exceptions.RealmFileException: Unable to open a realm at path '/data/data/com.package.name/files/db.realm': Bad Realm file header (#3). (Bad Realm file header (#3)) (/data/data/com.package.name/files/db.realm) in /home/cc/repo/realm/release/realm/realm-library/src/main/cpp/io_realm_internal_SharedRealm.cpp line 217
       at io.realm.internal.SharedRealm.nativeGetSharedRealm(SharedRealm.java)
       at io.realm.internal.SharedRealm.(SharedRealm.java)
       at io.realm.internal.SharedRealm.getInstance(SharedRealm.java:237)
       at io.realm.internal.SharedRealm.getInstance(SharedRealm.java:206)
       at io.realm.RealmCache.createRealmOrGetFromCache(RealmCache.java:127)
       at io.realm.Realm.getDefaultInstance(Realm.java:266)

Device stats (fairly no pattern): https://prnt.sc/g3ryyh
The only thing to mention is that crashing scenario is happening from new thread invoked from the service.

@beeender
Copy link
Contributor

beeender commented Aug 3, 2017

  1. What is your Realm version? Does the crash happen to a specific Realm version?
  2. Do you use encryption?
  3. Do you open Realm from multiple processes?

@AlexTip
Copy link
Author

AlexTip commented Aug 3, 2017

  1. Realm version - 3.5.0, crash reproduced in latest version 3.2+
  2. No
  3. No

@beeender
Copy link
Contributor

beeender commented Aug 3, 2017

Does it happen when you update the Realm from the older version to 3.5.0? If yes, what is the old version?

@AlexTip
Copy link
Author

AlexTip commented Aug 3, 2017

As far as I can see this crash was persistent for all the time in minor volumes about 10 crashes a day, but when we updated 3.1.4 to 3.4.0 and further the number of crashes started to grow incredibly.

@beeender
Copy link
Contributor

beeender commented Aug 3, 2017

Do you use Realm.compactRealm()?

@AlexTip
Copy link
Author

AlexTip commented Aug 3, 2017

No, the configuration is trivial enough

RealmConfiguration.Builder()
                .name(DATABASE_NAME)
                .schemaVersion(DATABASE_VERSION)
                .migration(new Migration())
                .build()

No additional features are used

@beeender
Copy link
Contributor

beeender commented Aug 3, 2017

Should be the same issue with realm/realm-core#2258 let's discuss there.

@Zhuinden
Copy link
Contributor

Zhuinden commented Aug 3, 2017

Technically "bad Realm file header" means corruption, but you currently don't seem to be doing anything that ought to cause corruption.

I guess the next question is:

  • how many threads try to start transaction concurrently (shouldn't cause a problem but hey), for example are Realm writes on a dedicated Realm-write-thread, or in AsyncTask/other threadpools

  • do you have two or more processes in your app,

  • is there a chance that you have multiple process AND execute migration in multiple processes at once by accident? (for example first Realm is opened inside Application class, and you have two processes)

@cmelchior
Copy link
Contributor

cmelchior commented Aug 16, 2017

@AlexTip Are you compacting your Realm at any point. We are seeing other reports that if it fails it appears to corrupt the original file: #5011

EDIT: Ups, it appears that @beeender already asked that. Ignore me

@cmelchior
Copy link
Contributor

Closing due to no response.

@ozv101
Copy link

ozv101 commented Dec 18, 2017

@cmelchior @beeender im seeing a few of these similiar issues opened and it seems like no one can reproduce them. is this something we're going to have to live with?

@Zhuinden
Copy link
Contributor

@ozv101 realm version, error / exception stack trace

@ozv101
Copy link

ozv101 commented Dec 19, 2017

@Zhuinden #5629

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants