novoda / download-manager

A library that handles long-running downloads, handling the network interactions and retrying downloads automatically after failures
Apache License 2.0
483 stars 63 forks source link

disk I/O error (code 4874): , while compiling: PRAGMA journal_mode #522

Open ouchadam opened 5 years ago

ouchadam commented 5 years ago

We're seeing crashes when the room database is initialised, from google'ing around, this error code is related to WAL.

I'm hoping upgrading to the latest version of room will address this as I can't find any recent references to the issue (which #519 addresses)

Have you seen this issue before?

Fatal Exception: android.database.sqlite.SQLiteDiskIOException: disk I/O error (code 4874): , while compiling: PRAGMA journal_mode
       at android.database.sqlite.SQLiteConnection.nativePrepareStatement(SQLiteConnection.java)
       at android.database.sqlite.SQLiteConnection.acquirePreparedStatement + 893(SQLiteConnection.java:893)
       at android.database.sqlite.SQLiteConnection.executeForString + 638(SQLiteConnection.java:638)
       at android.database.sqlite.SQLiteConnection.setJournalMode + 324(SQLiteConnection.java:324)
       at android.database.sqlite.SQLiteConnection.setWalModeFromConfiguration + 295(SQLiteConnection.java:295)
       at android.database.sqlite.SQLiteConnection.open + 219(SQLiteConnection.java:219)
       at android.database.sqlite.SQLiteConnection.open + 197(SQLiteConnection.java:197)
       at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked + 463(SQLiteConnectionPool.java:463)
       at android.database.sqlite.SQLiteConnectionPool.open + 185(SQLiteConnectionPool.java:185)
       at android.database.sqlite.SQLiteConnectionPool.open + 177(SQLiteConnectionPool.java:177)
       at android.database.sqlite.SQLiteDatabase.openInner + 806(SQLiteDatabase.java:806)
       at android.database.sqlite.SQLiteDatabase.open + 791(SQLiteDatabase.java:791)
       at android.database.sqlite.SQLiteDatabase.openDatabase + 694(SQLiteDatabase.java:694)
       at android.app.ContextImpl.openOrCreateDatabase + 557(ContextImpl.java:557)
       at android.content.ContextWrapper.openOrCreateDatabase + 269(ContextWrapper.java:269)
       at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked + 223(SQLiteOpenHelper.java:223)
       at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase + 163(SQLiteOpenHelper.java:163)
       at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.getWritableSupportDatabase + 96(FrameworkSQLiteOpenHelper.java:96)
       at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper.getWritableDatabase + 54(FrameworkSQLiteOpenHelper.java:54)
       at androidx.room.RoomDatabase.beginTransaction + 257(RoomDatabase.java:257)
       at com.novoda.downloadmanager.RoomBatchDao_Impl.loadAll + 154(RoomBatchDao_Impl.java:154)
       at com.novoda.downloadmanager.RoomDownloadsPersistence.loadBatches + 53(RoomDownloadsPersistence.java:53)
       at com.novoda.downloadmanager.DownloadsBatchPersistence.lambda$loadAsync$1 + 82(DownloadsBatchPersistence.java:82)
       at com.novoda.downloadmanager.DownloadsBatchPersistence.lambda$8CVCSwtAyFA3FRYxXHufn4v0C48(DownloadsBatchPersistence.java)
       at com.novoda.downloadmanager.-$$Lambda$ac$8CVCSwtAyFA3FRYxXHufn4v0C48.run(-.java)
       at java.util.concurrent.ThreadPoolExecutor.runWorker + 1113(ThreadPoolExecutor.java:1113)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run + 588(ThreadPoolExecutor.java:588)
       at java.lang.Thread.run + 818(Thread.java:818)

https://sqlite.org/rescode.html#ioerr_shmsize

The SQLITE_IOERR_SHMSIZE error code is an extended error code for SQLITE_IOERR indicating an I/O error within the xShmMap method on the sqlite3_io_methods object while trying to enlarge a "shm" file as part of WAL mode transaction processing. This error may indicate that the underlying filesystem volume is out of space.

Mecharyry commented 5 years ago

Yea I've seen this issue before 😢 I'm not sure why it is cropping up again though 😭

ouchadam commented 5 years ago

The error still occurs with the latest room upgrade, potentially we could catch the error and reopen the database connection in a non wal mode, although the docs suggest it could be due to the filesystem being out of space https://sqlite.org/rescode.html#ioerr_shmsize

although this commit would suggest a new status code will be returned SQLITE_FULL https://android.googlesource.com/platform/external/sqlite/+/1eb051da2d460037a748d574b128cdd33b6d8b28%5E!/


Can confirm this is happening when the device is low on storage

Screenshot 2019-10-14 at 09 51 04 Screenshot 2019-10-14 at 09 50 54