Transferred from #2402 No.2
Crash log at
http://crashes.to/s/24c6157fa0e
Exception see below
Fatal Exception: io.realm.exceptions.RealmError: Unrecoverable error. Bad transaction log in io_realm_internal_SharedGroup.cpp line 157
at io.realm.internal.SharedGroup.nativeAdvanceRead(SharedGroup.java)
at io.realm.internal.SharedGroup.advanceRead(SharedGroup.java:86)
at io.realm.internal.ImplicitTransaction.advanceRead(ImplicitTransaction.java:33)
at io.realm.internal.SharedGroupManager.advanceRead(SharedGroupManager.java:74)
at io.realm.HandlerController.realmChanged(HandlerController.java:333)
at io.realm.HandlerController.handleMessage(HandlerController.java:100)
at android.os.Handler.dispatchMessage(Handler.java:98)
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)
One of my users reported the above crash.
Caused by io.realm.exceptions.RealmError: Unrecoverable error. Bad transaction log in io_realm_internal_SharedGroup.cpp line 178
io.realm.internal.SharedGroup.nativePromoteToWrite (SharedGroup.java)
io.realm.internal.e.b (ImplicitTransaction.java:1145)
looks like it happens on the realm call beginTransaction()
Mobile: Samsung SM-G903F on Android 6.0.1
This happened in a doInBackground() method from an AsyncTask
The issue still occurs in Realm 2.1.1. The app crashes because of this issue at about 1% of all sessions, which is pretty serious. Restarting the app seems to clear the transaction log, as our users are only one time affected. The crashes are grouped in Fabric into two stacktraces:
Fatal Exception: io.realm.exceptions.RealmError: Unrecoverable error. Bad transaction log in /Users/zaki/fromgit/realm/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_SharedRealm.cpp line 113
at io.realm.internal.SharedRealm.nativeBeginTransaction(SharedRealm.java)
at io.realm.internal.SharedRealm.beginTransaction(SharedRealm.java:219)
at io.realm.BaseRealm.beginTransaction(BaseRealm.java:328)
at io.realm.Realm.beginTransaction(Realm.java:127)
at io.realm.Realm.executeTransaction(Realm.java:1253)
[...]
Fatal Exception: io.realm.exceptions.RealmError: Unrecoverable error. Bad transaction log in /Users/zaki/fromgit/realm/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_SharedRealm.cpp line 210
at io.realm.internal.SharedRealm.nativeRefresh(SharedRealm.java)
at io.realm.internal.SharedRealm.refresh(SharedRealm.java:281)
at io.realm.HandlerController.realmChanged(HandlerController.java:450)
at io.realm.HandlerController.handleMessage(HandlerController.java:121)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:5665)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:799)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:689)
So that means the errored methods are these
refresh: https://github.com/realm/realm-object-store/blob/master/src/shared_realm.cpp#L559-L584
beginTransaction: https://github.com/realm/realm-object-store/blob/master/src/shared_realm.cpp#L442-L455
The question is, why can the transaction log be corrupted?
@vonox7 My question is this: do you use synchronous queries, or asynchronous queries? Or both?
The insert is done via realm.executeTransaction { action(realm) }, the queries are all synchronous queries.
Android 4x, 5x
Realm 2.2.0
Use synchronous queries and asynchronous queries
Fatal Exception: java.lang.Error: io.realm.exceptions.RealmError: Unrecoverable error. Bad transaction log in /Users/cm/Realm/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_TableQuery.cpp line 1285
at io.realm.AndroidNotifier.throwBackgroundException(AndroidNotifier.java:138)
at io.realm.internal.async.QueryUpdateTask.run(QueryUpdateTask.java:128)
at io.realm.internal.async.BgPriorityRunnable.run(BgPriorityRunnable.java:34)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
Caused by io.realm.exceptions.RealmError: Unrecoverable error. Bad transaction log in /Users/cm/Realm/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_TableQuery.cpp line 1285
at io.realm.internal.TableQuery.nativeBatchUpdateQueries(TableQuery.java)
at io.realm.internal.TableQuery.batchUpdateQueries(TableQuery.java:500)
at io.realm.internal.async.QueryUpdateTask.run(QueryUpdateTask.java:87)
at io.realm.internal.async.BgPriorityRunnable.run(BgPriorityRunnable.java:34)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
Our investigation showed, that the error occurs only on encrypted realms and when writing concurrently from multiple threads. Can we send you a private demo-project that reproduces that (and many other) realm crashes?
@vonox7 YES PLEASE!! Please send the demo project to [email protected] and let us know the steps to reproduce it. Thanks A lot!
@beeender We sent you a mail containing the information ;)
We are also facing this issue with our customers. We are using v2.2.1.
Our use case very similar to @wbervoets where we are updating realm (encrypted) in the doInBackground method of AsyncTask.
also having this issue. It does happens in this scenario:
Imagining an activity that, at start, load data from realm and display it in a view (in my case, async on main thread). But at the same time, it also performs a network call (bg), get some data (bg), and insert in realm with insertall (bg).
The crash happens when the user quickly start the activity, and then press back. Repeat multiple times and it can be reproducible.
Xiaomi Redmi 6.0.1
Realm 2.3.0, encryption is on
Sync and async queries
02-06 14:03:17.077 25645-25645/? E/AndroidRuntime: FATAL EXCEPTION: main
PID: 25645
java.lang.Error: io.realm.exceptions.RealmError: Unrecoverable error. Bad transaction log in /home/cc/repo/realm/realm-java-release/realm/realm-library/src/main/cpp/io_realm_internal_TableQuery.cpp line 1297
at io.realm.AndroidNotifier.throwBackgroundException(Unknown Source)
at io.realm.internal.async.QueryUpdateTask.run(Unknown Source)
at io.realm.internal.async.BgPriorityRunnable.run(Unknown Source)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Caused by: io.realm.exceptions.RealmError: Unrecoverable error. Bad transaction log in /home/cc/repo/realm/realm-java-release/realm/realm-library/src/main/cpp/io_realm_internal_TableQuery.cpp line 1297
at io.realm.internal.TableQuery.nativeBatchUpdateQueries(Native Method)
at io.realm.internal.TableQuery.batchUpdateQueries(Unknown Source)
at io.realm.internal.async.QueryUpdateTask.run(Unknown Source)袙
at io.realm.internal.async.BgPriorityRunnable.run(Unknown Source)袙
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)袙
at java.util.concurrent.FutureTask.run(FutureTask.java:237)袙
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)袙
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)袙
at java.lang.Thread.run(Thread.java:818)袙
Potential fix for this https://github.com/realm/realm-core/pull/2426
The 2.3.2 release of Realm Java (containing the 2.3.2 core) fixed the issue for us. 馃憤
Thanks for fixing this bug, our crash rate dropped due to this fix by 80% :)
We are so happy to see this issue gets fixed!! Also I am very sorry that it took such a long time ... Anyway, thanks a lot for all your help to identify the issue!
Most helpful comment
The issue still occurs in Realm 2.1.1. The app crashes because of this issue at about 1% of all sessions, which is pretty serious. Restarting the app seems to clear the transaction log, as our users are only one time affected. The crashes are grouped in Fabric into two stacktraces: