realm / realm-kotlin

Kotlin Multiplatform and Android SDK for the Realm Mobile Database: Build Better Apps Faster.
Apache License 2.0
967 stars 61 forks source link

Realm is unable to open due to Failed to open Realm file at path error #1853

Closed DmytroTols closed 1 week ago

DmytroTols commented 3 weeks ago

How frequently does the bug occur?

Sometimes

Description

Unfortunately i wasn't lucky enough to reproduce this issue, but i so it in firebase when couple devices had this error. I can't get their database files, but i would be happy to help where i can.

I saw same error in java and swift libraries that seems to be fixed, but didn't find fixes for kotlin version

Stacktrace & log output

Caused by: java.lang.IllegalStateException: [RLM_ERR_INVALID_DATABASE]: Failed to open Realm file at path '/data/user/0/gr.edps.pax/files/tax-db': top ref is outside of the file (size: 4096, top_ref: 5552). The file has probably been truncated. top_ref[0]: 1538, top_ref[1]: 15B0, mnemonic: 54 2D 44 42, fmt[0]: 24, fmt[1]: 24, flags: 1
    at io.realm.kotlin.internal.interop.CoreErrorConverter.asThrowable(CoreErrorConverter.kt:47)
    at io.realm.kotlin.internal.interop.realmcJNI.realm_open(Native Method)
    at io.realm.kotlin.internal.interop.realmc.realm_open(realmc.java:434)
    at io.realm.kotlin.internal.interop.RealmInterop.realm_open(RealmInterop.kt:238)
    at io.realm.kotlin.internal.ConfigurationImpl$openRealm$2.invoke(ConfigurationImpl.kt:115)
    at io.realm.kotlin.internal.ConfigurationImpl$openRealm$2.invoke(ConfigurationImpl.kt:114)
    at io.realm.kotlin.internal.interop.NativePointerKt.use(NativePointer.kt:53)
    at io.realm.kotlin.internal.ConfigurationImpl.openRealm$suspendImpl(ConfigurationImpl.kt:114)
    at io.realm.kotlin.internal.ConfigurationImpl.openRealm(Unknown Source:0)
    at io.realm.kotlin.internal.RealmImpl$1.invokeSuspend(RealmImpl.kt:133)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
    at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:277)
    at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:95)
    at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:69)
    at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source:1)
    at io.realm.kotlin.internal.platform.CoroutineUtilsSharedJvmKt.runBlocking(CoroutineUtilsSharedJvm.kt:22)
    at io.realm.kotlin.internal.platform.CoroutineUtilsSharedJvmKt.runBlocking$default(CoroutineUtilsSharedJvm.kt:21)
    at io.realm.kotlin.internal.RealmImpl.<init>(RealmImpl.kt:115)
    at io.realm.kotlin.internal.RealmImpl.<init>(Unknown Source:0)
    at io.realm.kotlin.internal.RealmImpl$Companion.create$io_realm_kotlin_library(RealmImpl.kt:318)
    at io.realm.kotlin.Realm$Companion.open(Realm.kt:83)
    at com.pos.aade.sdk.AadeSdk$Companion$create$1$1$1.invoke(AadeSdk.kt:106)
    at com.pos.aade.sdk.AadeSdk$Companion$create$1$1$1.invoke(AadeSdk.kt:105)
    at org.koin.core.instance.InstanceFactory.create(InstanceFactory.kt:52)

Can you reproduce the bug?

No

Reproduction Steps

No response

Version

1.15.0

What Atlas App Services are you using?

Local Database only

Are you using encryption?

Yes

Platform OS and version(s)

Android 10

Build environment

Android Studio Koala | 2024.1.1 Patch 1 Build #AI-241.18034.62.2411.12071903, built on July 11, 2024 Runtime version: 17.0.11+0--11852314 amd64 Gradle version: 7.5

sync-by-unito[bot] commented 3 weeks ago

➤ PM Bot commented:

Jira ticket: RKOTLIN-1139

BlueCobold commented 1 week ago

1.15 is massively outdated. Did you try upgrading to 2.x?

DmytroTols commented 1 week ago

Thank you for you response, I will update my version and open new issue in case will get same error