Menu

Room 3 froze on a suspending @Transaction: the SQLite driver you pass picks your connection pool
📰

Room 3 froze on a suspending @Transaction: the SQLite driver you pass picks your connection pool

DEV Community: android·bitpage·about 3 hours ago
#QQ6fZzsF
Reading 0:00
15s threshold

Short answer: Room 3 does not manage connections the same way for every driver. It reads the hasConnectionPool property off whatever SQLiteDriver you pass to setDriver() , and that single boolean picks the concurrency model. AndroidSQLiteDriver returns true , so Room wraps it in PassthroughConnectionPool , which holds one thread-confined connection and has no acquisition timeout at all. A suspending @Transaction DAO function on that pool can block forever: the main thread stays idle, so there is no ANR, no crash, and no log line. Swapping to BundledSQLiteDriver makes Room run its own pool instead, and Room configures PRAGMA synchronous on every connection it opens, which quietly discards anything you set in RoomDatabase.Callback.onOpen .

TL;DR

Fix: pass a driver that reports hasConnectionPool = false ( BundledSQLiteDriver does, by inheriting the default) so Room manages its own pool.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.