getsentry / sentry-java

A Sentry SDK for Java, Android and other JVM languages.
https://docs.sentry.io/
MIT License
1.16k stars 435 forks source link

Fatal Exception: android.database.sqlite.SQLiteCantOpenDatabaseException #2924

Closed OHoussein closed 1 year ago

OHoussein commented 1 year ago

Integration

sentry-android

Build System

Gradle

AGP Version

7.4.0

Proguard

Enabled

Version

6.25.2

Steps to Reproduce

We spot the crash on production, but we are unable to reproduce it. it touches only a specific model: Transsion

Expected Result

App to be working correcly properly

Actual Result

Crasho on the app startup stack trace:

Fatal Exception: android.database.sqlite.SQLiteCantOpenDatabaseException: Cannot open database '/data/user/0/ng.com.fairmoney.fairmoney/databases/logger': File /data/user/0/ng.com.fairmoney.fairmoney/databases/logger doesn't exist
       at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:254)
       at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:205)
       at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:505)
       at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:206)
       at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:198)
       at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:928)
       at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:908)
       at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:772)
       at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:761)
       at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:373)
       at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:316)
       at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.getWritableSupportDatabase(FrameworkSQLiteOpenHelper.java:145)
       at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper.getWritableDatabase(FrameworkSQLiteOpenHelper.java:106)
       at io.sentry.android.sqlite.SentrySupportSQLiteOpenHelper$sentryWritableDatabase$2.invoke(SentrySupportSQLiteOpenHelper.kt:40)
       at io.sentry.android.sqlite.SentrySupportSQLiteOpenHelper$sentryWritableDatabase$2.invoke(SentrySupportSQLiteOpenHelper.kt:39)
       at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
       at io.sentry.android.sqlite.SentrySupportSQLiteOpenHelper.getSentryWritableDatabase(SentrySupportSQLiteOpenHelper.kt:39)
       at io.sentry.android.sqlite.SentrySupportSQLiteOpenHelper.getWritableDatabase(SentrySupportSQLiteOpenHelper.kt:48)
       at androidx.room.RoomDatabase.inTransaction(RoomDatabase.java:622)
       at androidx.room.RoomDatabase.assertNotSuspendingTransaction(RoomDatabase.java:399)
       at in.finbox.logger.c.b.a(b.java:1)
       at in.finbox.logger.Logger.deleteOldLogsIfNeeded$lambda-11(Logger.java:17)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
       at java.lang.Thread.run(Thread.java:1012)
romtsn commented 1 year ago

hi @OHoussein, thanks for using Sentry. I'd be curious why do you think our SDK is the root cause here? The error says:

 File /data/user/0/ng.com.fairmoney.fairmoney/databases/logger doesn't exist
       at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:254)

which can happen regardless of our database auto-instrumentation.

This looks more like an issue on one of the androidx libs (WorkManager or Room itself), e.g. this issue https://issuetracker.google.com/issues/152202040 or this https://issuetracker.google.com/issues/186443045

OHoussein commented 1 year ago

Hi @romtsn, thanks for your answer. It could be, but I expect the SDK not to work and make the failed access to the database a silent error instead of crashing the app, is that possible?

romtsn commented 1 year ago

@OHoussein but this is not our SDK that is using Room (we don't have any 3rd-party dependencies in our SDK), but your app:

       at in.finbox.logger.c.b.a(b.java:1)
       at in.finbox.logger.Logger.deleteOldLogsIfNeeded$lambda-11(Logger.java:17)

We're just wrapping the underlying SQLiteOpenHelper to provide auto-instrumentation of database queries, but no doing any actual operations on our end.

OHoussein commented 1 year ago

Clear, thanks for your clarification. Closing this issue.