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

App crashes with FORMAT_UPGRADE_REQUIRED while using Realm 7.0.0 #6889

Closed
73sravanthi opened this issue May 31, 2020 · 82 comments · Fixed by realm/realm-core#3910
Closed

App crashes with FORMAT_UPGRADE_REQUIRED while using Realm 7.0.0 #6889

73sravanthi opened this issue May 31, 2020 · 82 comments · Fixed by realm/realm-core#3910

Comments

@73sravanthi
Copy link

73sravanthi commented May 31, 2020

We have been using Realm from the past year, We recently upgraded the application from V6.1.0 to V7.0.0, post this upgrade we are witnessing the crash mentioned, we are using Kotlin for application development with Realm java and lastly, we have enabled DB encryption

Process: com.com.myapp.Application.qa, PID: 31558
java.lang.RuntimeException: Unable to create application com.myapp.Application: io.realm.exceptions.RealmFileException: Opening Realm files of format version 0 is not supported by this version of Realm (Database has an unsupported version and cannot be upgraded
Exception backtrace:
(/data/data/com.myapp.Application:/files/myapp.realm) in /Users/cm/Realm/realm-java-release/realm/realm-library/src/main/cpp/io_realm_internal_OsSharedRealm.cpp line 107 Kind: FORMAT_UPGRADE_REQUIRED.
at io.realm.internal.OsSharedRealm.nativeGetSharedRealm(Native Method)
at io.realm.internal.OsSharedRealm.(OsSharedRealm.java:175)
at io.realm.internal.OsSharedRealm.getInstance(OsSharedRealm.java:251)
at io.realm.BaseRealm.(BaseRealm.java:137)
at io.realm.BaseRealm.(BaseRealm.java:104)
at io.realm.Realm.(Realm.java:163)
at io.realm.Realm.createInstance(Realm.java:499)
at io.realm.RealmCache.createInstance(RealmCache.java:507)
at io.realm.RealmCache.doCreateRealmOrGetFromCache(RealmCache.java:473)
at io.realm.RealmCache.createRealmOrGetFromCache(RealmCache.java:414)
at io.realm.Realm.getDefaultInstance(Realm.java:407)

@73sravanthi 73sravanthi changed the title App crashes with FORMAT_UPGRADE_REQUIRED when using Realm 7.0.0 App crashes with FORMAT_UPGRADE_REQUIRED while using Realm 7.0.0 May 31, 2020
@cmelchior
Copy link
Contributor

How are you opening the Realm?

@73sravanthi
Copy link
Author

DB configuration :
RealmLivedataWrapper.init(context)
val config = RealmConfiguration.Builder()
.name(BuildConfig.REALM_FILE_NAME)
.modules(Realm.getDefaultModule(), DataRealmModules())
.encryptionKey(StorageKeyUtils.getKey(sharedPreferences, context))
.schemaVersion(BuildConfig.REALM_SCHEMA_VERSION)
.migration(DbMigration())
.build()
Realm.setDefaultConfiguration(config)

realmLivedataWrapper = RealmLivedataWrapper.Builder()
  .setRealmConfiguration(config)
  .build()

While navigating between the modules its crashing at
val realm: Realm = Realm.getDefaultInstance()

@cmelchior
Copy link
Contributor

Weird. The error message seems to indicate that you are opening an older already existing file. Is that the case?

@73sravanthi
Copy link
Author

It's crashing while navigating from one module to another after some modifications. We have used Realm v6.1.0. This issue is observed when upgraded to v7.0.0 .

@73sravanthi
Copy link
Author

The same scenario is working fine with Realm v6.1.0

@73sravanthi
Copy link
Author

Will there be any issue if we use following method in 7.0.0

val realm: Realm = Realm.getDefaultInstance()
realm.sharedRealm.refresh()
try {
realm.executeTransaction { realmInstance ->
realmInstance.copyToRealmOrUpdate(dataObjects)
}
} catch (ex: Exception) {
Log.d("DOWNLOAD_ERROR", "storeToLocal DB store EXCEPTION")
Log.d(this::class.java.simpleName, ex.message)
} finally {
realm.refreshAndClose()
}

@73sravanthi
Copy link
Author

Hi.Any update on the above issue? We are facing the above crash with above error in multiple places .

@edgar-zigis
Copy link

I have noticed this error too. We have only upgraded realm version and did not touch schema itself.
Mostly it occurs on Android 10 devices. Most popular devices which failed to upgrade:

Samsung Galaxy A70
Xiaomi Mi9 SE
Nokia 5

Other devices seemed to work fine, but this is quite critical.

@ganfra
Copy link

ganfra commented Jun 24, 2020

Exactly the same issue on our side, reproduced on my Pixel 3 on Android 9.

@cmelchior
Copy link
Contributor

@ganfra Can you share how to reproduce? If you want to keep it private you can email me at christian.melchior@mongodb.com

@ganfra
Copy link

ganfra commented Jun 26, 2020

If you are brave enough you can test it on our open-source project: https://github.com/vector-im/riotX-android
Updating realm to 7.0.0, then after some initial launches it will crash with this issue.
(Also, not related at all, but we are having massive performance issues when db is getting big)

@ganfra
Copy link

ganfra commented Jun 26, 2020

So I created a test account where you will be able to reproduce the error:
Login: realm7
Password: realm7.0help

You should use the develop branch.

So here is how to reproduce

  1. compile the app with realm 6.1.0 (in the matrix-sdk-android gradle file).
  2. launch and log in with given credentials.
  3. Compile the app with realm 7.0.0
  4. Relaunch the app, use the app a bit.
  5. kill the app and relaunch => it should crash. If not, kill and relaunch until it crashes

Tell me if you need more information :)

@ganfra
Copy link

ganfra commented Jun 30, 2020

@cmelchior : any chance you could look at it?

@cmelchior
Copy link
Contributor

cmelchior commented Jul 1, 2020

@ganfra Thank you for the project. I am able to reproduce the problem. We are looking into it.

A few things ruled out:

  • It isn't a wrong encryption key causing this issue or lack of key completely.

@ganfra
Copy link

ganfra commented Jul 7, 2020

Did you have any lead on what could be wrong?

@patelnishantk
Copy link

@cmelchior Would appreciate any update on this. Unfortunately, we too face this issue after upgrading from v6.1.0 to v7.0.0. It has resulted into hundreds of crashes reported in Firebase in barely few hours.

@cmelchior
Copy link
Contributor

@patelnishantk Unfortunately we still don't have a root cause for this.

@ppamorim
Copy link

ppamorim commented Aug 1, 2020

We are experiencing the same issue with a single client.

@ppamorim
Copy link

ppamorim commented Sep 16, 2020

@ganfra Be aware that already corrupted databases won't be restored (in my case). We had to create a special app to export critical data from our apps. Far from ideal and a bit humiliating. :( I would like to see the Realm team speaking more about it. @jedelbo Could you please refer to the PR? Was it in the core?

@jedelbo
Copy link

jedelbo commented Sep 16, 2020

Be aware that the file is not corrupted.We just fail to read the file correctly. The issue was fixed in realm/realm-core#3910.

@ppamorim
Copy link

@jedelbo I did export 3 databases + encryption keys and I could not open any of them on Realm Studio. All of them where around 700mb for an unknown reason. That's why I suspect that the file was corrupt.

@ganfra
Copy link

ganfra commented Sep 16, 2020

Same issue of 700mb size, but I did manage to see this issue before releasing the app, so no problem for me...

@jedelbo
Copy link

jedelbo commented Sep 16, 2020

@ganfra so you see an unexpected increase in size? How big a difference is there compared to earlier?

@ganfra
Copy link

ganfra commented Sep 16, 2020

Generally the file is 150mb in this usecase. Multiple time after this crash it grows to 700mb as I said.

@ppamorim
Copy link

ppamorim commented Sep 16, 2020

@jedelbo Could you please confirm if the latest version is capable of opening these large databases and if it's able to reduce the file size?

I saw that you recently did a change in the core but this version on this library is not out, is there any way to release this version anytime soon?

@jedelbo
Copy link

jedelbo commented Sep 17, 2020

The Java team is working out getting the release out later today.

We are able to handle realms of any practical size. You can use CompactOnLaunch to reduce the size of a realm. However we are of course interested in keeping the size of the realm down, so we would be interested in investigating why you experience this growth in size. So would you be willing and able to share a 'before' and 'after' realm with us? You can share the files privately by mail (jorgen.edelbo@mongodb.com).

@ppamorim
Copy link

I think @ganfra will be able to provide a database, I could not replicate the issue on my side and the data that I have cannot be shared.

@ppamorim
Copy link

@jedelbo Any update?

@ppamorim
Copy link

@cmelchior The version 7.0.2 didn't sort the issue. We are going to update it to version 7.0.5. The situation is bad.

@cmelchior
Copy link
Contributor

We will be making a 7.0.6 release in the next few hours that should have a fix for this.

@jedelbo
Copy link

jedelbo commented Sep 18, 2020

You should wait for v7.0.6. It should be just around the corner.

@prettyClouds
Copy link

Is there any kind of public pipeline we can monitor to get an idea of when things will release?

@cmelchior
Copy link
Contributor

You can watch releases on Bintray here: https://bintray.com/realm/maven/realm-android-library

@cmelchior
Copy link
Contributor

7.0.6 was just released which should fix this. Please reopen the issue if you still see it after upgrading.

@ppamorim
Copy link

@cmelchior The version 7.0.6 is still not available, any timeframe or workaround for the moment?

@cmelchior
Copy link
Contributor

It should be available now.

@ganfra
Copy link

ganfra commented Sep 18, 2020

Ok so now I can't reproduce, looking good! Thanks for this long-awaited fix!

@ppamorim
Copy link

@ganfra Hi, were you able to open that 700mb realm file too?

@ganfra
Copy link

ganfra commented Sep 21, 2020

Didn't try, but I got a SEGFAULT 11 and a corrupted file just after, so shout victory too quickly...

@ppamorim
Copy link

ppamorim commented Sep 21, 2020

@ganfra Very nice, imagine living in a world where the database of your application gets corrupted due to a bug.

@ppamorim
Copy link

@ganfra Some users were able to restore the app. I got one case where the app wasn't able to load the database.

@ganfra
Copy link

ganfra commented Sep 28, 2020

@ppamorim thanks for letting me know, but I just keep getting native crashes on some other parts

@sampathkumar1988
Copy link

Hi Team, We are getting this crash in our production. Not able to reproduce though. Any solutions ?

CRASH TYPE SUMMARY
LOCATION
SourceFile line -2 in io.realm.internal.OsSharedRealm.nativeGetSharedRealm()
EXCEPTION
io.realm.exceptions.RealmFileException
MESSAGE
Opening Realm files of format version 22 is not supported by this version of Realm (Database has an unsupported version and cannot be upgraded Exception backtrace: ) (/data/data/com.company.au.gma/files/company-sdk-account.storage) in /Users/cm/Realm/realm-java-release/realm/realm-library/src/main/cpp/io_realm_internal_OsSharedRealm.cpp line 107

Note: We are using the 7.0.8 realm version

Thanks

@jedelbo
Copy link

jedelbo commented Apr 11, 2022

@sampathkumar1988 Seems like you are opening a file produced by a newer version of realm with a rather old version.

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

Successfully merging a pull request may close this issue.