We've recently encountered this crash but haven't been able to identify the root cause, as the error appears to be coming from WorkManager.
Workmanager version: androidx.work:work-runtime-ktx:2.7.0
The crash mostly occurs on Oppo, Vivo, and Samsung devices running Android 11, with 95% of the cases happening in the background.
Fatal Exception: android.database.sqlite.SQLiteDatabaseLockedException
database is locked (code 5 SQLITE_BUSY)
android.database.sqlite.SQLiteConnection.nativeExecute (SQLiteConnection.java)
android.database.sqlite.SQLiteConnection.execute (SQLiteConnection.java:717)
android.database.sqlite.SQLiteSession.beginTransactionUnchecked (SQLiteSession.java:321)
android.database.sqlite.SQLiteSession.beginTransaction (SQLiteSession.java:300)
android.database.sqlite.SQLiteDatabase.beginTransaction (SQLiteDatabase.java:575)
android.database.sqlite.SQLiteDatabase.beginTransactionNonExclusive (SQLiteDatabase.java:509)
androidx.sqlite.db.framework.FrameworkSQLiteDatabase.beginTransactionNonExclusive (FrameworkSQLiteDatabase.java:74)
androidx.room.RoomDatabase.internalBeginTransaction (RoomDatabase.java:570)
androidx.room.RoomDatabase.beginTransaction (RoomDatabase.java:555)
androidx.work.impl.Schedulers.schedule (Schedulers.java:71)
androidx.work.impl.WorkerWrapper.onWorkFinished (WorkerWrapper.java:375)
androidx.work.impl.WorkerWrapper$2.run (WorkerWrapper.java:331)
androidx.work.impl.utils.SerialExecutor$Task.run (SerialExecutor.java:91)
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1167)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:641)
java.lang.Thread.run (Thread.java:923)
I'm not sure where to look because the error doesn't specify which database is causing the issue. Additionally, I'm unable to reproduce the issue on either an emulator or the real devices I currently have.