realm / realm-java

Realm is a mobile database: a replacement for SQLite & ORMs
http://realm.io
Apache License 2.0
11.45k stars 1.74k forks source link

RealmError: Incompatible lock file / After 2.0 RealmFileException All processes sharing a single file must be the same architecture. #2459

Closed hohnamkung closed 6 years ago

hohnamkung commented 8 years ago

Goal

To report specific error after upgrading v0.88.0

Expected Results

Crash is not occurred.

Actual Results

Fatal Exception: io.realm.exceptions.RealmError: Unrecoverable error. Incompatible lock file in io_realm_internal_SharedGroup.cpp line 113
   at io.realm.internal.SharedGroup.createNativeWithImplicitTransactions(SharedGroup.java)
   at io.realm.internal.SharedGroup.(SharedGroup.java:63)
   at io.realm.internal.SharedGroupManager.(SharedGroupManager.java:48)
   at io.realm.BaseRealm.(BaseRealm.java:76)
   at io.realm.Realm.(Realm.java:138)
   at io.realm.Realm.createAndValidate(Realm.java:268)
   at io.realm.Realm.createInstance(Realm.java:248)
   at io.realm.RealmCache.createRealmOrGetFromCache(RealmCache.java:114)
   at io.realm.Realm.getInstance(Realm.java:213)
   at kr.co.vcnc.android.couple.feature.MainTabIndicator.updateHomeBadge(MainTabIndicator.java:138)
   at kr.co.vcnc.android.couple.feature.MainTabIndicator.onAttachedToWindow(MainTabIndicator.java:83)
   at android.view.View.dispatchAttachedToWindow(View.java:12626)
   at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2473)
   at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2480)
   at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2480)
   at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2480)
   at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2480)
   at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2480)
   at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2480)
   at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2480)
   at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2480)
   at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2480)
   at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1264)
   at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1047)
   at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5896)
   at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
   at android.view.Choreographer.doCallbacks(Choreographer.java:574)
   at android.view.Choreographer.doFrame(Choreographer.java:544)
   at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
   at android.os.Handler.handleCallback(Handler.java:733)
   at android.os.Handler.dispatchMessage(Handler.java:95)
   at android.os.Looper.loop(Looper.java:136)
   at android.app.ActivityThread.main(ActivityThread.java:5120)
   at java.lang.reflect.Method.invokeNative(Method.java)
   at java.lang.reflect.Method.invoke(Method.java:515)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
   at dalvik.system.NativeStart.main(NativeStart.java)

Steps & Code to Reproduce

I got this stack trace from Fabric. I've tested several devices that we have, i can't reproduce it. Instead, i attached some code that error is happening.

FYI, at this update (to v0.88.0), we upgraded Realm's schema version. (We're using deleteRealmIfMigrationNeeded option)

Code Sample

@Override
protected void onAttachedToWindow() {
    homeBadgeSubscription = Realm.getInstance(CoupleApplication.getRealmHome())
                .where(RHomeCardViewView.class)
                .equalTo("closed", false)
                .equalTo("newIndicator", true)
                .findAllAsync()
                .asObservable()
                .filter(RealmResults::isLoaded)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(BasicSubscriber.    <RealmResults<RHomeCardViewView>>create().next(homeCardViewViews -> {
                    int size = homeCardViewViews.size();
                    updateTextView(size);
                }));

@Override
protected void onDetachedFromWindow() {
    if (homeBadgeSubscription != null) {
        homeBadgeSubscription.unsubscribe();
    }
}

Version of Realm and tooling

Realm version(s): v0.88.0

Which Android version and device: When i first saw this crash, i think this is occurred because users are using BlackBerry. But now Android users have a crash.

screen shot 2016-03-15 at 10 55 28 am screen shot 2016-03-15 at 10 55 40 am screen shot 2016-03-15 at 10 55 47 am

The peak point is yesterday. (Realm v0.88.0) screen shot 2016-03-15 at 10 59 39 am

beeender commented 8 years ago

@hohnamkung

  1. Can you share the latest apk with us? to help@realm.io
  2. Are you using Realm in different processes? eg. Some services are running in a different process and accessing the same Realm which is used in the main activity as well.
beeender commented 8 years ago

Is it the first time when the getInstance() gets called in the app?

hohnamkung commented 8 years ago

Yes. I've just tested. Realm.getInstance(CoupleApplication.getRealmHome()) is first invoked at that point.

We're using single process (don't declare any process in AndroidManifest.xml) In AppWidgetProvider we query realm (same configuration, CoupleApplication.getRealmHome), but i think that that code run on same process. (http://stackoverflow.com/a/11017453/4444109)

beeender commented 8 years ago

@hohnamkung Two more questions:

  1. Do you have any more information about how many crashed devices are 64bit?
  2. Do you ship the Realm's arm64 so with the apk?
beeender commented 8 years ago

APK at https://secure.helpscout.net/conversation/181563825/3381/?folderId=366141

hohnamkung commented 8 years ago
  1. I'm not sure how many it is, but top 3 devices in Samsung and LG are 32bit OS screen shot 2016-03-16 at 10 28 31 am
  2. No. I excluded it on purpose to prevent some device from can't load so file exception.

    packagingOptions {
       // Workaround for failing to fall back to choose a non-64bit version of so
       exclude "lib/arm64-v8a/librealm-jni.so"
       exclude "lib/x86_64/librealm-jni.so"
    }
beeender commented 8 years ago

@hohnamkung We just released 0.88.2, it has a potential fix of this problem (which i am not sure could solve this, but worth a try), and some more information about the exception is added to help us debug if it still happens. And it also has a fix for the bad version problem you have.

Would you please give it a try? And let us know if this problem is still there. thanks a lot, and sorry for those troubles.

hohnamkung commented 8 years ago

@beeender I'll release new version using 0.88.2 sooner than later! Thanks!

hohnamkung commented 8 years ago

Hi @beeender After update, i still have a problem (Exception log is a little changed)

Fatal Exception: io.realm.exceptions.RealmError: Unrecoverable error. Incompatible lock file. Shared info version doesn't match, 4 5. in io_realm_internal_SharedGroup.cpp line 113
   at io.realm.internal.SharedGroup.createNativeWithImplicitTransactions(SharedGroup.java)
   at io.realm.internal.SharedGroup.(SharedGroup.java:64)
   at io.realm.internal.SharedGroupManager.(SharedGroupManager.java:49)
   at io.realm.BaseRealm.(BaseRealm.java:76)
   at io.realm.Realm.(Realm.java:138)
   at io.realm.Realm.createAndValidate(Realm.java:268)
   at io.realm.Realm.createInstance(Realm.java:248)
   at io.realm.RealmCache.createRealmOrGetFromCache(RealmCache.java:114)
   at io.realm.Realm.getInstance(Realm.java:213)
   at kr.co.vcnc.android.couple.feature.MainTabIndicator.updateHomeBadge(MainTabIndicator.java:138)
   at kr.co.vcnc.android.couple.feature.MainTabIndicator.onAttachedToWindow(MainTabIndicator.java:83)
   at android.view.View.dispatchAttachedToWindow(View.java:12658)
   at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2473)
   at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2480)
   at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2480)
   at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2480)
   at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2480)
   at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2480)
   at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2480)
   at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2480)
   at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2480)
   at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2480)
   at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1255)
   at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1038)
   at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5889)
   at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
   at android.view.Choreographer.doCallbacks(Choreographer.java:574)
   at android.view.Choreographer.doFrame(Choreographer.java:544)
   at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
   at android.os.Handler.handleCallback(Handler.java:733)
   at android.os.Handler.dispatchMessage(Handler.java:95)
   at android.os.Looper.loop(Looper.java:136)
   at android.app.ActivityThread.main(ActivityThread.java:5118)
   at java.lang.reflect.Method.invokeNative(Method.java)
   at java.lang.reflect.Method.invoke(Method.java:515)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:610)
   at dalvik.system.NativeStart.main(NativeStart.java)
beeender commented 8 years ago

Thanks a lot for the information, i will check and get back to you ASAP.

hohnamkung commented 8 years ago

And another crash log is collected. If you think that it's is a another problem, i'll make a other issue.

Fatal Exception: java.lang.IllegalArgumentException: Illegal Argument: Invalid format of Realm file.
   at io.realm.internal.SharedGroup.createNativeWithImplicitTransactions(SharedGroup.java)
   at io.realm.internal.SharedGroup.(SharedGroup.java)
   at io.realm.internal.SharedGroupManager.(SharedGroupManager.java)
   at io.realm.BaseRealm.(BaseRealm.java)
   at io.realm.Realm.(Realm.java)
   at io.realm.Realm.createAndValidate(Realm.java:268)
   at io.realm.Realm.createInstance(Realm.java:248)
   at io.realm.RealmCache.createRealmOrGetFromCache(RealmCache.java:114)
   at io.realm.Realm.getInstance(Realm.java:213)
   at kr.co.vcnc.android.couple.feature.MainTabIndicator.updateHomeBadge(MainTabIndicator.java:138)
   at kr.co.vcnc.android.couple.feature.MainTabIndicator.onAttachedToWindow(MainTabIndicator.java:83)
   at android.view.View.dispatchAttachedToWindow(View.java:11888)
   at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2521)
   at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2528)
   at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2528)
   at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2528)
   at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2528)
   at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2528)
   at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2528)
   at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2528)
   at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2528)
   at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2528)
   at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1207)
   at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1006)
   at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4225)
   at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
   at android.view.Choreographer.doCallbacks(Choreographer.java:555)
   at android.view.Choreographer.doFrame(Choreographer.java:525)
   at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
   at android.os.Handler.handleCallback(Handler.java:615)
   at android.os.Handler.dispatchMessage(Handler.java:92)
   at android.os.Looper.loop(Looper.java:213)
   at android.app.ActivityThread.main(ActivityThread.java:4786)
   at java.lang.reflect.Method.invokeNative(Method.java)
   at java.lang.reflect.Method.invoke(Method.java:511)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
   at dalvik.system.NativeStart.main(NativeStart.java)
beeender commented 8 years ago

Please create another issue for that, it seems to be another problem. Thanks!

dalinaum commented 8 years ago

http://crashes.to/s/0762fe58804

dalinaum commented 8 years ago

@hohnamkung has confirmed that @beeender's workaround works well.

appsailor commented 8 years ago

@dalinaum I have an app in play store [https://play.google.com/store/apps/details?id=com.isletsystems.android.cricitch.lite] that is growing steadily, and is experiencing the same error @hohnamkung detailed, in my most recent build that I published.

I had built the app with the following:

error from crashlytics: Fatal Exception: io.realm.exceptions.RealmError: Unrecoverable error. Incompatible lock file. Shared info version doesn't match, 4 5. in io_realm_internal_SharedGroup.cpp line 113 at io.realm.internal.SharedGroup.createNativeWithImplicitTransactions(SharedGroup.java) at io.realm.internal.SharedGroup.(SharedGroup.java:64) at io.realm.internal.SharedGroupManager.(SharedGroupManager.java:49) at io.realm.BaseRealm.(BaseRealm.java:76) at io.realm.Realm.(Realm.java:138) at io.realm.Realm.createAndValidate(Realm.java:268) at io.realm.Realm.createInstance(Realm.java:248) at io.realm.RealmCache.createRealmOrGetFromCache(RealmCache.java:114) at io.realm.Realm.getInstance(Realm.java:213) at com.isletsystems.android.cricitch.app.CricitchApplication.onCreate(CricitchApplication.java:69) at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1013) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4609) at android.app.ActivityThread.access$1600(ActivityThread.java:169) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1337) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5476) at java.lang.reflect.Method.invokeNative(Method.java) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099) at dalvik.system.NativeStart.main(NativeStart.java)

screen shot 2016-03-31 at 8 40 40 pm

Looking forward to a new release of realm java with a fix for the same.

beeender commented 8 years ago

@appsailor Can you list those devices which have this problem? Maybe we are lucky enough to have one of them to reproduce the issue.

appsailor commented 8 years ago

@beeender here are those devices experiencing problems.

screen shot 2016-04-01 at 3 43 55 am screen shot 2016-04-01 at 3 42 06 am screen shot 2016-04-01 at 3 40 42 am
appsailor commented 8 years ago

Any luck with this issue getting resolved? Thx in advance.

beeender commented 8 years ago

@appsailor Sorry, but we still have no luck to reproduce the issue...

beeender commented 8 years ago

@appsailor Sent a mail to you email address :)

shliama commented 8 years ago

Same issue here with version 0.88.3. I'll update to 0.90.1 in the next app update.

Fatal Exception: io.realm.exceptions.RealmError: Unrecoverable error. Incompatible lock file. Shared info version doesn't match, 4 5. in io_realm_internal_SharedGroup.cpp line 113
       at io.realm.internal.SharedGroup.createNativeWithImplicitTransactions(SourceFile)
       at io.realm.internal.SharedGroup.(SourceFile)
       at io.realm.internal.SharedGroupManager.(SourceFile)
       at io.realm.BaseRealm.(SourceFile)
       at io.realm.Realm.(SourceFile)
       at io.realm.Realm.createAndValidate(SourceFile:268)
       at io.realm.Realm.createInstance(SourceFile:248)
       at io.realm.RealmCache.createRealmOrGetFromCache(SourceFile:114)
       at io.realm.Realm.getDefaultInstance(SourceFile:195)
       at com.transpose.core.manager.FilesManager.checkFileUploadQueue(SourceFile:107)
       at com.transpose.core.sync.TransposeSyncAdapter.onPerformSync(SourceFile:125)
       at android.content.AbstractThreadedSyncAdapter$SyncThread.run(AbstractThreadedSyncAdapter.java:259)

Devices are:

Samsung t320 87% Samsung n9005 7% Samsung n915p 3%

Also Blackberry Z10 & Passport

Call to Realm.getDefaultInstance() from above stacktrace is coming from SyncAdapter (another thread). Also it can be called from the UI thread.

hufozhu commented 8 years ago

Still get same error after upgrade realm to 0.91.0-SNAPSHOT, is it useful to delete realm file when I get this error?

kneth commented 8 years ago

@hufozhu If you use Realm as a cache, and you can reload data from other sources, you can delete the Realm file (which will also remove the lock files).

hufozhu commented 8 years ago

@kneth Thanks for quick reply. What I really want to know is whether this error only occurs when there is a old realm file. Our app gets this error from about 0.5% of our users, and since 0.91.0-SNAPSHOT does not resolve this error, I want to delete old realm for this 0.5% users if it is useful. Thanks!

kneth commented 8 years ago

@hufozhu We haven't been able to reproduce the issue, so I can't really say if it is related to old Realm files only. It is an interesting observation, and it might give us a clue.

I don't know what kind of data your app's Realm files contain, and therefore I can't give you a definite advice on whether you can delete the files or not.

0.5 % sounds like a high number to me. Do you see any patterns in which devices with the issue? Can you reproduce the issue?

Is there a remote chance that you open a Realm in one thread and copying a Realm file from assets in another thread at the same time?

hufozhu commented 8 years ago

@kneth Thanks for reply. I decide to delete old file when app gets this error in our new version, hope it is helpful. We release new version to about 2000 users and this error comes from 9 user. All 9 user use android 4.4 (the most popular version in China). I cannot reproduce it on all my devices. But next week we will release new version to public, after which millions of users will install new version, maybe I can provide more information for you. We do not copy realm file from assets, but we do realm migration to two different realm file in two thread. Do you think this action maybe this reason?

kneth commented 8 years ago

No, migrating is in a sense nothing more than a special write transaction, and the two files are independent. My concern was that you copied a Realm file from the asset in one thread while executing a transaction in another. Overwriting an open file could give you weird errors.

Today, we have released a new version with a few fixes. We will be happy to hear from you if you see this issue when you have a larger user base. If you're based in China, I'm sure that @beeender will be happy to contact you.

hufozhu commented 8 years ago

@kneth I am sure that no copying of realm file happens in our project. Happy to heard new version of realm is released, we may upgrade to new version with next release. I will provide more information if the next week release still get this error, and I would appreciate that if @beeender can help us on this. Thanks again for your help. Good day!

Qubitium commented 8 years ago

We just upgraded from realm 0.87.3(ish) to 0.91.0. Had 1 crash due to this:

Device: Lenovo A5000 (4.4.2)

Fatal Exception: io.realm.exceptions.RealmError: Unrecoverable error. Incompatible lock file. Info size doesn't match, 1112 1120. in io_realm_internal_SharedGroup.cpp line 113
       at io.realm.internal.SharedGroup.createNativeWithImplicitTransactions(SharedGroup.java)
       at io.realm.internal.SharedGroup.<init>(SharedGroup.java:64)
       at io.realm.internal.SharedGroup.<init>(SharedGroup.java:64)
       at io.realm.RealmConfiguration.getEncryptionKey(RealmConfiguration.java:124)
       at io.realm.internal.SharedGroupManager.<init>(SharedGroupManager.java:49)
       at io.realm.BaseRealm.<init>(BaseRealm.java:79)
       at io.realm.Realm.<init>(Realm.java:138)
       at io.realm.Realm.createAndValidate(Realm.java:248)
       at io.realm.Realm.createInstance(Realm.java:228)
       at io.realm.RealmCache.createRealmOrGetFromCache(RealmCache.java:126)
       at io.realm.Realm.getInstance(Realm.java:192)
cmelchior commented 8 years ago

We have fixed subtle cases in 1.0.0 which could lead to the crash reported here. We will close the issue for now, but If you experience the issue again with our latest release, please open an issue.

ghost commented 8 years ago

@cmelchior when is the ETA for 1.0.0?

cmelchior commented 8 years ago

Any minute now ;)

Zhuinden commented 8 years ago

@rimeissner I added 1.0.0 gradle plugin and it worked.

vytautasgimbutas commented 8 years ago

We're still having this issue, even though we've upgrade to 1.0.0.

Fatal Exception: io.realm.exceptions.RealmError: Unrecoverable error. Incompatible lock file. Info size doesn't match, 1112 1120. in io_realm_internal_SharedGroup.cpp line 113 at io.realm.internal.SharedGroup.createNativeWithImplicitTransactions(SharedGroup.java) at io.realm.internal.SharedGroup.(SharedGroup.java:64) at io.realm.internal.SharedGroupManager.(SharedGroupManager.java:49) at io.realm.BaseRealm.(BaseRealm.java:79) at io.realm.Realm.(Realm.java:138) at io.realm.Realm.createAndValidate(Realm.java:248) at io.realm.Realm.createInstance(Realm.java:228) at io.realm.RealmCache.createRealmOrGetFromCache(RealmCache.java:126) at io.realm.Realm.getInstance(Realm.java:192)

beeender commented 8 years ago

Reopen since it is still happening. #2928

Qubitium commented 8 years ago

New crash from LenovoA3300-GV (4.4.2). But this time, we logged more info.

1) Crashed realm was first copied from as /assets folder to a r/w path to be later opened by realm and be update-able. The copy is performed right before the realm is opened and in the same thread. 2) Prior to copying, we removed all .lock/.log/.note files that might have lingered from previous. 3) Sometime prior to the crash, a realm migration was performed on a completely separate realm. The migration was as follows: a) create many new int.class columns. b) do transformation to copy/port String data into new int.class columns c) remove old String.class columns d) rename int.class columns to previously removed columns 4) The crashed device was previous on an app version with realm version < 0.91.0 (most likely 0.87.3) and just upgraded to app version with realm 1.0.0 and opening up the app for the first time presumably. 5) There is at least 1 and at most 2 realms open at the time of the crash.

That's all the info we have.


Caused by io.realm.exceptions.RealmError: Unrecoverable error. Incompatible lock file. Info size doesn't match, 1112 1120. in io_realm_internal_SharedGroup.cpp line 113
       at io.realm.internal.SharedGroup.createNativeWithImplicitTransactions(SharedGroup.java)
       at io.realm.internal.SharedGroup.<init>(SharedGroup.java:64)
       at io.realm.internal.SharedGroup.<init>(SharedGroup.java:64)
       at io.realm.RealmConfiguration.getEncryptionKey(RealmConfiguration.java:126)
       at io.realm.internal.SharedGroupManager.<init>(SharedGroupManager.java:49)
       at io.realm.BaseRealm.<init>(BaseRealm.java:79)
       at io.realm.Realm.<init>(Realm.java:138)
       at io.realm.Realm.createAndValidate(Realm.java:248)
       at io.realm.Realm.createInstance(Realm.java:228)
       at io.realm.RealmCache.createRealmOrGetFromCache(RealmCache.java:126)
       at io.realm.Realm.getInstance(Realm.java:192)
lisawray commented 8 years ago

We're getting this too on our latest release, the first where we heavily use Realm. For about 0.5% of our users. Almost all Samsung. This release is using Realm 0.90.0.

We don't ever copy the DB file, but we do delete it in cases where it's not worth it to migrate. We also access the DB in a SyncAdapter that might be trying to run at application start when we're accomplishing Realm deletion/ recreation / migration.

Fatal Exception: io.realm.exceptions.RealmError: Unrecoverable error. Incompatible lock file. Info size doesn't match, 1112 1120. in io_realm_internal_SharedGroup.cpp line 113 at io.realm.internal.SharedGroup.createNativeWithImplicitTransactions(SourceFile) at io.realm.internal.SharedGroup.(SourceFile:64) at io.realm.internal.SharedGroupManager.(SourceFile:49) at io.realm.BaseRealm.(SourceFile:77) at io.realm.Realm.(SourceFile:138) at io.realm.Realm.createAndValidate(SourceFile:269) at io.realm.Realm.createInstance(SourceFile:249) at io.realm.RealmCache.createRealmOrGetFromCache(SourceFile:118) at io.realm.Realm.getDefaultInstance(SourceFile:195) at com.genius.android.sync.GeniusRealmWrapper.(SourceFile:52) at com.genius.android.sync.GeniusRealmWrapper.getDefaultInstance(SourceFile:67) at com.genius.android.GeniusApplication.onCreate(SourceFile:53) at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1014) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4747) at android.app.ActivityThread.access$1500(ActivityThread.java:166) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1343) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5584) at java.lang.reflect.Method.invokeNative(Method.java) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084) at dalvik.system.NativeStart.main(NativeStart.java)

image

cmelchior commented 8 years ago

@diegomontoya @lisawray @hohnamkung We are not seeing many reports for this error, but e.g @lisawray seems to have some users experience it more than once. Do you mind sending your AndroidManifest.xml + dependency list from build.gradle to help@realm.io. I am hoping that can help us find some common features between your apps that might give us a clue to what is causing this.

lisawray commented 8 years ago

@cmelchior sent.

indeed ... we have some persistent users. that's like 10 crashes apiece. I haven't gotten a single personal report of this yet, so I don't know if it's crashing the app, but I assume so ...

image

cmelchior commented 8 years ago

Hi @lisawray and @hohnamkung Thanks for the files. I am going over them and you have a few commonalities I am looking into, unfortunately we have nothing concrete yet.

However after internal discussion and input from the outside I don't think we can rule out that two processes might be running during app upgrades which will manifest with the error described here. To prevent that we implemented a new scheme for opening Realm files which means it will retry optimistically for 3 seconds before finally giving up and crashing (like now). The PR is here #3013 and have been released as part of our 1.0.1 today.

For the happy path this doesn't have any effect, but if users encounter the error, the app will now appear frozen for up to 3 seconds before finally crashing like before or actually continuing.

If users encounter this error and our solution fixes it, a warning will be logged to LogCat.

1) If possible, can you try to upgrade to 1.0.1. 2) Our RealmLog class takes a custom logger implementation so if you happen to use any sort of analytic tool. Please try to add a custom logger that tracks if such a warning is created. I will be happy to help you do this.

I'll keep this issue open until we are more why this issue is happening and what can be done to fix it.

ghost commented 8 years ago

One thing I just realised ist that we get Unrecoverable error. Incompatible lock file. Info size doesn't match, 1112 1120. in io_realm_internal_SharedGroup.cpp line 113 for an In-Memory realm on first initialisation of the app (in Applications onCreate).

beeender commented 8 years ago

@rimeissner If the root cause is what we expected (see https://github.com/realm/realm-java/issues/2459#issuecomment-226520214), the same root cause could be applied to the in-mem realm as well.

For a in-mem realm, it will also create a realm file underneath along with the lock files (kind of temporary files, but they are needed.). So if it is possible, please update to v1.0.1 to see if can solve the issue.

ghost commented 8 years ago

Ty @beeender We should be able to release a fix today, I will share the results

ToBoehmK commented 8 years ago

Hi Realm team. We are confronted with the same problem. Updating to v1.0.1 did not solve it.

kneth commented 8 years ago

@ToBoehmK Sorry to hear that. Can you provide more details? The best is if you have a project which can reproduce the crash. Otherwise, log files, tombstones or a link to crashlytics can also be helpful.

jturolla commented 8 years ago

I'm having a similar issue. Just upgraded from 0.87 to 1.1.0 (with migrations).

This report also comes from fabric, devices:

Fatal Exception: io.realm.exceptions.RealmError: Could not open the Realm file: Incompatible lock file. Shared info version doesn't match, 4 7.
       at io.realm.internal.SharedGroup.openSharedGroupOrFail(SharedGroup.java:112)
       at io.realm.internal.SharedGroup.<init>(SharedGroup.java:74)
       at io.realm.internal.SharedGroupManager.<init>(SharedGroupManager.java:49)
       at io.realm.BaseRealm.<init>(BaseRealm.java:81)
       at io.realm.Realm.<init>(Realm.java:140)
       at io.realm.Realm.createAndValidate(Realm.java:240)
       at io.realm.Realm.createInstance(Realm.java:220)
       at io.realm.RealmCache.createRealmOrGetFromCache(RealmCache.java:126)
       at io.realm.Realm.getDefaultInstance(Realm.java:166)
       at com.parafuzo.tasker.service.LoginService.currentTasker(LoginService.java:45)
       at com.parafuzo.tasker.service.LoginService.isLoggedIn(LoginService.java:36)
       at com.parafuzo.tasker.activity.LoginActivity.onCreate(LoginActivity.java:62)
       at android.app.Activity.performCreate(Activity.java:5296)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2283)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2370)
       at android.app.ActivityThread.access$800(ActivityThread.java:155)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1243)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:136)
       at android.app.ActivityThread.main(ActivityThread.java:5426)
       at java.lang.reflect.Method.invokeNative(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:515)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
       at dalvik.system.NativeStart.main(NativeStart.java)
rodrigoolr commented 8 years ago

I've got two exceptions that are equal to the one listed above from an application in 1.1.0. We had no migration since its our first release with realm. They come from different points of the application, so it seems quite random, but I can't tell for sure.

Devices:

beeender commented 8 years ago

@ToBoehmK @jturolla @rodrigoolr How do your users upgrade the app? Through google play store? Or the app supports downloading & installing apk directly in the app?

rodrigoolr commented 8 years ago

@beeender We upgrade only through play store

rodrigoolr commented 8 years ago

Do you guys have any news on this issue? We have a couple of crashes on our latest versions due to this. Is there any information we could give that could help solving it?