Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQLiteDatabaseLockedException: database is locked #964

Open
mwshubham opened this issue Feb 17, 2023 · 3 comments
Open

SQLiteDatabaseLockedException: database is locked #964

mwshubham opened this issue Feb 17, 2023 · 3 comments
Labels
help wanted Extra attention is needed

Comments

@mwshubham
Copy link

✍️ Describe the bug

💣 Steps to reproduce

Not able to reproduce it. This might be due to multiple process used by our application

Stack Trace:
2023-02-15 18:17:29.037 5055-6422/? E/AndroidRuntime: FATAL EXCEPTION: DefaultDispatcher-worker-3 Process: com.eterno:stickyProcess, PID: 5055 android.database.sqlite.SQLiteDatabaseLockedException: database is locked (code 5 SQLITE_BUSY) at android.database.sqlite.SQLiteConnection.nativeExecute(Native Method) at android.database.sqlite.SQLiteConnection.execute(SQLiteConnection.java:707) at android.database.sqlite.SQLiteSession.beginTransactionUnchecked(SQLiteSession.java:321) at android.database.sqlite.SQLiteSession.beginTransaction(SQLiteSession.java:300) at android.database.sqlite.SQLiteDatabase.beginTransaction(SQLiteDatabase.java:571) at android.database.sqlite.SQLiteDatabase.beginTransactionNonExclusive(SQLiteDatabase.java:505) at androidx.sqlite.db.framework.a.c(FrameworkSQLiteDatabase.java:78) at androidx.room.RoomDatabase.q(RoomDatabase.java:570) at androidx.room.RoomDatabase.j(RoomDatabase.java:555) at com.chuckerteam.chucker.internal.data.room.b$7.a(HttpTransactionDao_Impl.java:333) at com.chuckerteam.chucker.internal.data.room.b$7.call(HttpTransactionDao_Impl.java:330) at androidx.room.CoroutinesRoom$Companion$execute$2.a(CoroutinesRoom.kt:65) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.b(ContinuationImpl.kt:33) at kotlinx.coroutines.ar.run(DispatchedTask.kt:106) at androidx.room.ae$1.run(TransactionExecutor.java:47) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:923) Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [cf{Cancelling}@2e14398, Dispatchers.IO]

🔧 Expected behavior

Application should not crash for such scenario

📷 Screenshots

NA

📱 Tech info

  • Device: NA
  • OS: NA
  • Chucker version: 3.5.2

📄 Additional context

NA

@cortinico cortinico added the help wanted Extra attention is needed label Feb 22, 2023
@cortinico
Copy link
Member

Ideally a reproducer here would be help to debug what's going on 👍

@mwshubham
Copy link
Author

mwshubham commented Apr 28, 2023

This could be due to this faq
https://www.sqlite.org/faq.html#q5

When SQLite tries to access a file that is locked by another process, the default behaviour is to return SQLITE_BUSY. You can adjust this behaviour from C code using the sqlite3_busy_handler() or sqlite3_busy_timeout() API functions.

We can use the content provider approach if the DB operation is performed on a process other than the main process.

@cortinico
Copy link
Member

I believe we might be able to fix this by specifying enableMultiInstanceInvalidation() when creating the Room DB. Having a reproducer of your app would help greatly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants