apptentive / apptentive-android

Apptentive Android SDK
http://www.apptentive.com
BSD 3-Clause "New" or "Revised" License
65 stars 64 forks source link

Database lock in getOldestUnsentPayload #61

Closed bishopmatthew closed 10 years ago

bishopmatthew commented 10 years ago

I'm seeing this crash in the logs for my app (so far there are about 60 crashes per week from this).

Is there a reason you don't catch the exception here?

https://github.com/apptentive/apptentive-android/blob/master/apptentive-android-sdk/src/com/apptentive/android/sdk/storage/ApptentiveDatabase.java#L206

Because I feel that a library like this shouldn't really be letting internal exceptions be thrown that crash the app.

Crashed Thread
android.database.sqlite.SQLiteException: not an error (code 0): Could not open the database in read/write mode.
at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:318)
at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:229)
at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:515)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:207)
at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:178)
at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:875)
at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:843)
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:696)
at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:1145)
at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:236)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:224)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:164)
at com.apptentive.android.sdk.storage.ApptentiveDatabase.getOldestUnsentPayload(ApptentiveDatabase.java:207)
at com.apptentive.android.sdk.storage.PayloadSendWorker$PayloadRunner.run(PayloadSendWorker.java:57)
skykelsey commented 10 years ago

Hey Matt,

I've pushed out release 1.2.3.

Among other things, this release traps exceptions emanating from our code, and reports them back to our server so we can proactively fix their causes. I'm not whether a solution to the root cause of this issue is possible, but at least it won't crash your app anymore. Thanks!