Room 1.1.0 version.
I am getting this error on the first run after migration.
It runs well if I close the app and start it again.
ROOM: Cannot run invalidation tracker. Is the db closed?
java.lang.IllegalStateException: Cannot perform this operation because the connection pool has been closed.
at android.database.sqlite.SQLiteConnectionPool.throwIfClosedLocked(SQLiteConnectionPool.java:1182)
at android.database.sqlite.SQLiteConnectionPool.waitForConnection(SQLiteConnectionPool.java:792)
at android.database.sqlite.SQLiteConnectionPool.acquireConnection(SQLiteConnectionPool.java:518)
Caused By : SQL(query) error or missing database.
(no such table: room_table_modification_log (code 1): , while compiling: DELETE FROM proposals WHERE hotel_id = ?)
#################################################################
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:1095)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:660)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:59)
at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
at android.database.sqlite.SQLiteDatabase.compileStatement(SQLiteDatabase.java:1417)
at android.arch.persistence.db.framework.FrameworkSQLiteDatabase.compileStatement(FrameworkSQLiteDatabase.java:64)
at android.arch.persistence.room.RoomDatabase.compileStatement(RoomDatabase.java:244)
at android.arch.persistence.room.SharedSQLiteStatement.createNewStatement(SharedSQLiteStatement.java:65)
at android.arch.persistence.room.SharedSQLiteStatement.getStmt(SharedSQLiteStatement.java:77)
at android.arch.persistence.room.SharedSQLiteStatement.acquire(SharedSQLiteStatement.java:87)
at com.hotellook.db.dao.FavoritesDao_Impl.removeProposals(FavoritesDao_Impl.java:723)
The DB initialization code looks like this (Dagger AppModule)
@Provides
@Singleton
fun provideDataBase(app: Application): AppDatabase =
Room.databaseBuilder(app, AppDatabase::class.java, DATABASE_NAME)
.addMigrations(MIGRATION_1_2)
.addMigrations(MIGRATION_2_3)
.build()
private companion object {
const val DATABASE_NAME = "app.db"
val MIGRATION_1_2 = object : Migration(1, 2) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL("ALTER TABLE table1 ADD COLUMN column0 TEXT;")
database.execSQL("ALTER TABLE table2 ADD COLUMN column0 TEXT;")
}
}
val MIGRATION_2_3 = object : Migration(2, 3) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL("CREATE TABLE table0 (column1 INTEGER NOT NULL, column2 TEXT NOT NULL, PRIMARY KEY(column1))")
database.execSQL("ALTER TABLE table1 ADD COLUMN column1 TEXT;")
database.execSQL("ALTER TABLE table1 ADD COLUMN column2 TEXT;")
database.execSQL("ALTER TABLE table1 ADD COLUMN column3 REAL;")
database.execSQL("ALTER TABLE table2 ADD COLUMN column1 TEXT;")
database.execSQL("ALTER TABLE table2 ADD COLUMN column2 REAL;")
database.execSQL("ALTER TABLE table3 ADD COLUMN column1 INTEGER DEFAULT 0;")
database.execSQL("ALTER TABLE table3 ADD COLUMN column2 TEXT;")
}
}
The app upgrades from version 2 to 3. How can I fix it?
Bump up the version to 1.1.1-rc1 and this nonsensical error that stems from Google's own code will not happen anymore, I've tested the same scenario on numerous devices.
Also see my question/answer here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With