Status Update
Comments
il...@google.com <il...@google.com> #2
Is there any updates? This is a big problem!
ga...@freeletics.com <ga...@freeletics.com> #3
Hi there - could you provide more context on the issue & a sample project to reproduce? Database locked exceptions are quite difficult to pinpoint without a repro project. Thanks!
mg...@google.com <mg...@google.com>
Ni...@fressnapf.com <Ni...@fressnapf.com> #4
Hi. It is reproduceable on some users by using this code:
suspend fun <R> MyDatabase.workaroundWithTransaction(block: suspend TransactionScope<R>.() -> R) {
useWriterConnection {
it.immediateTransaction(block)
}
// TODO: Temporally fix https://issuetracker.google.com/issues/340606803#comment2
// Manually triggers invalidation
invalidationTracker.refreshAsync()
}
mg...@google.com <mg...@google.com> #6
Hi. Please merge the pull request. This is big problem!
nu...@traderepublic.com <nu...@traderepublic.com> #8
Hi, I updated my version to alpha12 but still have these crashes. Please release a fix asap.
mg...@google.com <mg...@google.com> #9
Will there be fixes released this Wednesday?
pr...@google.com <pr...@google.com> #10
Hey, there is no release on Wednesday (holiday in the USA)
We haven't found the root cause of this exception, it happens when SQLite can't commit the transaction because some other connection has a lock, we need more information, a sample project that reproduces the issue preferably, or more details on how the database is being used (is it from multiple process? is there heavy concurrency?).
You can also increase the time SQLite will wait before it error with 'database locked' by executing PRAGMA busy_timeout = <time in ms>
, the current default is 3000
m....@gmail.com <m....@gmail.com> #11
Thank you for you response.
- Isn't these pull request addressed this issue?
1.1
https://android-review.googlesource.com/c/platform/frameworks/support/+/3408679 1.2https://android-review.googlesource.com/c/platform/frameworks/support/+/3114928 - According to RoomDB documentation about
withTransaction
: "Room will only perform at most one transaction at a time, additional transactions are queued and executed on a first come, first serve order." So the transaction should just wait for other transaction to complete and not throw exception instead. Isn't it?
mg...@google.com <mg...@google.com> #12
I tried to use this code and still getting the same error from users. (deferredTransaction
instead of immediateTransaction
)
private val dbMutex = Mutex()
suspend fun <R> MyDatabse.workaroundWithTransaction(block: suspend TransactionScope<R>.() -> R) {
dbMutex.withLock {
useWriterConnection {
it.deferredTransaction(block)
}
// TODO: Fix https://issuetracker.google.com/issues/340606803#comment2
// Manually triggers invalidation
invalidationTracker.refreshAsync()
}
}
m....@gmail.com <m....@gmail.com> #13
Moreover now I am also think that @Update
function caused particularly this crash. I will monitor the situation to this if this 1 crash or it will be more with the same reason.
mg...@google.com <mg...@google.com> #14
After checking I can confirm that this crash happens as many as before.
pe...@mohemian.com <pe...@mohemian.com> #15
The crash occurs when the user adds a new record to the database from the interface, and the crash occurs when the application starts in the first 1-2 seconds. The crash also occurs when receiving records from the database.
This is just a disaster, please fix it.
mg...@google.com <mg...@google.com> #16
Sorry, I don't believe those two pull request address the issue you are seeing.
If you can reliably reproduce can you please send us a sample project?
Besides adding a Mutex
did you also try increasing the busy timeout with the PRAGMA? Can you please share more details how the database is being used? Are you starting a transaction and performing many @Update
? Is the coroutine where the transaction occurring getting canceled and restarted? The theory here is maybe cancelation is not recycling the connection correctly and there is a lingering transaction that prevents other ones from finishing.
Can you also try and configure Room with the AndroidSQLiteDriver()
? This would help us know if the issue is specific to the BundledSQLiteDriver
or not.
I have yet to reproduce to issue, I've tried creating 'stress tests' like the following:
@Test
fun daoUsagesInTransaction() = runTest {
List(100) {
launch(Dispatchers.IO) {
db.useWriterConnection { transactor ->
transactor.immediateTransaction {
val e = SampleEntity(1)
db.dao().insert(e)
db.dao().update(e)
db.dao().delete(e)
}
}
db.invalidationTracker.refreshAsync()
}
}.joinAll()
}
pr...@google.com <pr...@google.com> #17
Hi. Thank you for your response.
- My app have BroadcastReceivers and WorkManagers that reads and writes in the same database that the app does. Could it be the problem? But! The logic didn't change since I moved from android only to shared module. On android it was working just fine.
- Currently I didn't succeed in reproducing it by myself.
- Have I tried to reproduce it by stress tests? Yes, but I haven't get the crash.
- "did you also try increasing the busy timeout with the PRAGMA?" - No, I didn't. I thought that it may be command just for my local device for testing. I google it see that I could execute it in query format when setting up Room. But I don't have so match long data read of write. I and thinking about it now.
- "Can you please share more details how the database is being used?" - As example of my app: task tracking app. The user enters tasks via UI, tasks sync with other user device, task can show local alerts notification to remind.
- "Are you starting a transaction and performing many @Update?" - It could do non-users operations when:
- Starts the app the notes are being sent or received (the App scope).
- Starts the app the other data updated via WorkManager (the WorkManager scope).
- Receives alert notification and BroadcastReceivers plans new notification and updates info about it in database (BroadcastReceiver scope).
- "The theory here is maybe cancelation is not recycling the connection correctly and there is a lingering transaction that prevents other ones from finishing." - I am now trying to ger rid of WorkManagers because I heard that they may start in another process then the app. I will see if it would help.
- "Can you also try and configure Room with the AndroidSQLiteDriver()?" - I tried to implement it but I don't understand how. My database placed in common module. The RoomDB generates implementation for each platform. How could I make my android implementation so I could use
AndroidSQLiteDriver()
?
Description
This is basically an follow-up of https://issuetracker.google.com/issues/336842920 .
Component used:
Version used:
Devices/Android versions reproduced on: Android 14
We see the the following crashes directly at app start when using R8 (with default AGP 8.x fullMode enabled): IllegalStateException: CompositionLocal LocalLifecycleOwner not present
We saw the added proguard rules inhttps://android-review.googlesource.com/c/platform/frameworks/support/+/3105647/21/lifecycle/lifecycle-runtime-compose/proguard-rules.pro
Changing them to
fixes the crash.
So it seems the keep rule is currently not sufficient to make 2.8.2 compatible with Compose 1.6 when minify the build.