sqlcipher / android-database-sqlcipher

Android SQLite API based on SQLCipher
https://www.zetetic.net/sqlcipher/sqlcipher-for-android/
Other
2.73k stars 564 forks source link

AndroidRuntime: net.sqlcipher.database.SQLiteException: no such table: room_table_modification_log: , while compiling: SELECT * FROM room_table_modification_log WHERE invalidated = 1; #640

Open Alexanderlwz opened 4 months ago

Alexanderlwz commented 4 months ago

Steps to Reproduce

I have a scenario where the database is closed and reopened after initialization. I am encountering an issue intermittently.

SQLCipher version (can be identified by executing PRAGMA cipher_version;): 4.5.3

SQLCipher for Android version:

Are you able to reproduce this issue within the SQLCipher for Android test suite? No. Hard to reproduce locally.

01-11 12:18:01.655 10177 8943 9008 E ROOM : Invalidation tracker is initialized twice :/. 01-11 12:18:01.667 10177 8943 9085 E AndroidRuntime: FATAL EXCEPTION: arch_disk_io_1 01-11 12:18:01.667 10177 8943 9085 E AndroidRuntime: Process: com.telenav.launcher, PID: 8943 01-11 12:18:01.667 10177 8943 9085 E AndroidRuntime: net.sqlcipher.database.SQLiteException: no such table: room_table_modification_log: , while compiling: SELECT * FROM room_table_modification_log WHERE invalidated = 1; 01-11 12:18:01.667 10177 8943 9085 E AndroidRuntime: at net.sqlcipher.database.SQLiteCompiledSql.native_compile(Native Method) 01-11 12:18:01.667 10177 8943 9085 E AndroidRuntime: at net.sqlcipher.database.SQLiteCompiledSql.compile(Unknown Source:15) 01-11 12:18:01.667 10177 8943 9085 E AndroidRuntime: at net.sqlcipher.database.SQLiteCompiledSql.(Unknown Source:30) 01-11 12:18:01.667 10177 8943 9085 E AndroidRuntime: at net.sqlcipher.database.SQLiteProgram.(Unknown Source:105) 01-11 12:18:01.667 10177 8943 9085 E AndroidRuntime: at net.sqlcipher.database.SQLiteQuery.(SourceFile:4) 01-11 12:18:01.667 10177 8943 9085 E AndroidRuntime: at net.sqlcipher.database.SQLiteDatabase.query(SourceFile:11) 01-11 12:18:01.667 10177 8943 9085 E AndroidRuntime: at net.sqlcipher.database.SQLiteDatabase.query(SourceFile:6) 01-11 12:18:01.667 10177 8943 9085 E AndroidRuntime: at androidx.room.RoomDatabase.query(SourceFile:5) 01-11 12:18:01.667 10177 8943 9085 E AndroidRuntime: at androidx.room.RoomDatabase.query$default(Unknown Source:7) 01-11 12:18:01.667 10177 8943 9085 E AndroidRuntime: at androidx.room.InvalidationTracker$refreshRunnable$1.checkUpdatedTable(Unknown Source:19) 01-11 12:18:01.667 10177 8943 9085 E AndroidRuntime: at androidx.room.InvalidationTracker$refreshRunnable$1.run(Unknown Source:109) 01-11 12:18:01.667 10177 8943 9085 E AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 01-11 12:18:01.667 10177 8943 9085 E AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 01-11 12:18:01.667 10177 8943 9085 E AndroidRuntime: at java.lang.Thread.run(Thread.java:923)

BTW: InvalidationTracker Line 438 catch Android's SQLiteException but here is net.sqlcipher.database.SQLiteException which extends from RuntimeException.

            // This transaction has to be on the underlying DB rather than the RoomDatabase
            // in order to avoid a recursive loop after endTransaction.
            SupportSQLiteDatabase db = mDatabase.getOpenHelper().getWritableDatabase();
            db.beginTransactionNonExclusive();
            try {
                invalidatedTableIds = checkUpdatedTable();
                db.setTransactionSuccessful();
            } finally {
                db.endTransaction();
            }
        } catch (IllegalStateException | SQLiteException exception) {
            // may happen if db is closed. just log.
            Log.e(Room.LOG_TAG, "Cannot run invalidation tracker. Is the db closed?",
                    exception);

Thanks for your help.

developernotes commented 4 months ago

Hi @Alexanderlwz,

I suspect this may be a bug within the Room API, the same Room log message has been reported in the Google Issue Tracker ^1 previously. You might consider reaching out there. Also, the android-database-sqlcipher library has been deprecated, sqlcipher-android is the long-term replacement ^2.

Alexanderlwz commented 4 months ago

Thank you, I'll migrate to sqlcipher-android.