Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android SQLiteDiskIOException (code 522 SQLITE_IOERR_SHORT_READ)

I am on Android O and using Room database, from time to time, I experience SQLiteDisckIOException, I try to troubleshoot problem but the stack doesn't tell me where the failing point is. Can some give me some hint or how to troubleshoot this kind of problem and what is the potential problem here? The app that I am writing will write to database when location change, and also there are couple background task that periodic update database when needed.

Here is the stack I see:

10-07 22:29:41.404 22214-22226/? E/DataBuffer: Internal data leak within a DataBuffer object detected!  Be sure to explicitly call release() on all DataBuffer extending objects when you are done with them. (internal object: com.google.android.gms.common.data.DataHolder@b0fef92)
10-07 22:29:41.405 22214-22226/? E/DataBuffer: Internal data leak within a DataBuffer object detected!  Be sure to explicitly call release() on all DataBuffer extending objects when you are done with them. (internal object: com.google.android.gms.common.data.DataHolder@db3ad63)
10-07 22:29:41.415 19847-19847/com.firsapp.testing E/Periodic: from PIM->onCreateOptionMenu
10-07 22:29:41.442 19847-21824/com.firsapp.testing E/SQLiteLog: (522) statement aborts at 7: [SELECT DISTINCT tag FROM worktag WHERE work_spec_id=?] disk I/O error
10-07 22:29:41.443 19847-21824/com.firsapp.testing E/SQLiteQuery: exception: disk I/O error (code 522 SQLITE_IOERR_SHORT_READ); query: SELECT DISTINCT tag FROM worktag WHERE work_spec_id=?
10-07 22:29:41.449 19847-21824/com.firsapp.testing E/AndroidRuntime: FATAL EXCEPTION: pool-6-thread-2
        Process: com.firsapp.testing, PID: 19847
        android.database.sqlite.SQLiteDiskIOException: disk I/O error (code 522 SQLITE_IOERR_SHORT_READ)
        at android.database.sqlite.SQLiteConnection.nativeExecuteForCursorWindow(Native Method)
        at android.database.sqlite.SQLiteConnection.executeForCursorWindow(SQLiteConnection.java:859)
        at android.database.sqlite.SQLiteSession.executeForCursorWindow(SQLiteSession.java:836)
        at android.database.sqlite.SQLiteQuery.fillWindow(SQLiteQuery.java:62)
        at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:149)
        at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:137)
        at androidx.work.impl.model.WorkTagDao_Impl.getTagsForWorkSpecId(WorkTagDao_Impl.java:92)
        at androidx.work.impl.WorkerWrapper.run(WorkerWrapper.java:102)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:764)
10-07 22:29:41.579 890-890/? E/lowmemorykiller: Error writing /proc/19847/oom_score_adj; errno=22
like image 630
spiderloop Avatar asked Oct 08 '18 03:10

spiderloop


1 Answers

From the SQLite documentation SQLITE_IOERR_SHORT_READ refers to a case where the database was unable to read the requested number of bytes from the file system.

https://www.sqlite.org/rescode.html#ioerr_short_read

Do you allow your apps to be installed on the external storage directory ? https://developer.android.com/guide/topics/manifest/manifest-element.html#install

My guess is that:

  • Either the file system on the device is problematic.
  • The app was in an external storage directory, and the SD card was removed while the user was using your app, and that caused SQLite to throw this exception.
like image 196
Rahul Avatar answered Oct 15 '22 05:10

Rahul