Electric-Coin-Company / zcash-android-wallet-sdk

Native Android SDK for Zcash
MIT License
5 stars 9 forks source link

SQLiteCantOpenDatabaseException in `SQLiteDatabaseExtKt.queryAndMap` #1434

Open HonzaR opened 4 months ago

HonzaR commented 4 months ago

Describe the issue

Sometimes (under some conditions we don't know exactly yet), the SDK's SQLite database gets into a malformed data state. This state comes from SQLiteDatabaseExtKt.queryAndMap

This is related to https://github.com/Electric-Coin-Company/zcash-android-wallet-sdk/issues/214 and https://github.com/Electric-Coin-Company/zcash-android-wallet-sdk/issues/240.

Can you reliably reproduce the issue?

If so, please list the steps to reproduce below:

Expected behaviour

Actual behavior + errors

Any extra information that might be useful in the debugging process.

Fatal Exception: android.database.sqlite.SQLiteCantOpenDatabaseException: unable to open database file (code 14 SQLITE_CANTOPEN)
       at android.database.sqlite.SQLiteConnection.nativeExecuteForCursorWindow(SQLiteConnection.java)
       at android.database.sqlite.SQLiteConnection.executeForCursorWindow(SQLiteConnection.java:1034)
       at android.database.sqlite.SQLiteSession.executeForCursorWindow(SQLiteSession.java:862)
       at android.database.sqlite.SQLiteQuery.fillWindow(SQLiteQuery.java:62)
       at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:145)
       at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:132)
       at android.database.AbstractCursor.moveToPosition(AbstractCursor.java:252)
       at cash.z.ecc.android.sdk.internal.db.SQLiteDatabaseExtKt$queryAndMap$2.invokeSuspend(SQLiteDatabaseExt.kt:109)
       at cash.z.ecc.android.sdk.internal.db.SQLiteDatabaseExtKt$queryAndMap$2.invoke(SQLiteDatabaseExt.kt:12)
       at cash.z.ecc.android.sdk.internal.db.SQLiteDatabaseExtKt$queryAndMap$2.invoke(SQLiteDatabaseExt.kt:12)
       at kotlinx.coroutines.flow.SafeFlow.collectSafely(Builders.kt:61)
       at kotlinx.coroutines.flow.AbstractFlow.collect(AbstractFlow.java:230)
       at kotlinx.coroutines.flow.internal.ChannelFlowOperatorImpl.flowCollect(ChannelFlow.kt:195)
       at kotlinx.coroutines.flow.internal.ChannelFlowOperator.collectTo$suspendImpl(ChannelFlow.kt:157)
       at kotlinx.coroutines.flow.internal.ChannelFlowOperator.collectTo(ChannelFlow.kt:5)
       at kotlinx.coroutines.flow.internal.ChannelFlow$collectToFun$1.invokeSuspend(ChannelFlow.kt:60)
       at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
       at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
       at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.java:115)
       at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:103)
       at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.java:584)
       at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793)
       at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697)
       at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)