Status Update
Comments
ae...@gmail.com <ae...@gmail.com> #2
@Suppress("UNCHECKED_CAST")
class DelegateWorker: Worker() {
companion object {
const val DELEGATE_WORKER_NAME = "DELEGATE_WORKER_NAME"
const val PERIOD = "PERIOD" // in minutes.
}
override fun doWork(): Result {
val delegateName = inputData.getString(DELEGATE_WORKER_NAME) ?: return Result.FAILURE
val delegateKlass = Class.forName(delegateName) as? Class<out Worker> ?: return Result.FAILURE
val period = inputData.getLong(PERIOD, 15)
// build your worker with the constraints you want.
val request = PeriodicWorkRequest.Builder(delegateKlass, period, TimeUnit.MINUTES)
.setInputData(inputData)
.build()
WorkManager.getInstance()
.enqueue(request)
return Result.SUCCESS
}
}
class PeriodicWorker: Worker() {
override fun doWork(): Result {
// Do some periodic work
return Result.SUCCESS
}
}
// You want to delay the PeriodicWorker. You can use initial delay on the DelegateWorker, which in
// turn enqueue's PeriodicWorker.
val data = mapOf(DelegateWorker.DELEGATE_WORKER_NAME to PeriodicWorker::
val delayedPeriodicWorkRequest = OneTimeWorkRequestBuilder<DelegateWorker>()
.setInitialDelay(10, TimeUnit.SECONDS)
.build()
WorkManager.getInstance()
.enqueue(delayedPeriodicWorkRequest)
The idea is to create a OneTimeWorkRequest with an initial delay, which in turn calls an enqueue() on the PeriodicWorkReqeust.
el...@google.com <el...@google.com> #3
ae...@gmail.com <ae...@gmail.com> #4
ae...@gmail.com <ae...@gmail.com> #5
#4: Please file a separate bug if that doesn't work for you.
ae...@gmail.com <ae...@gmail.com> #6
ae...@gmail.com <ae...@gmail.com> #7
ae...@gmail.com <ae...@gmail.com> #8
ae...@gmail.com <ae...@gmail.com> #9
da...@google.com <da...@google.com> #10
1. Periodic work request does not support setInitialDelay.
2. Periodic Work request does not support the Chining.
ae...@gmail.com <ae...@gmail.com> #11
"Periodic work has a minimum interval of 15 minutes and it cannot have an initial delay."
"Periodic work cannot be part of a chain or graph of work."
ae...@gmail.com <ae...@gmail.com> #12
I feel that many people need it...would make so much sense to be able to have setInitialDelay() on PeriodicWorkRequest.Builder
ae...@gmail.com <ae...@gmail.com> #13
ae...@gmail.com <ae...@gmail.com> #14
ae...@gmail.com <ae...@gmail.com> #15
da...@google.com <da...@google.com> #16
ae...@gmail.com <ae...@gmail.com> #17
This behaviour is documented:
The call creates a PeriodicWorkRequest to run periodically once within the flex period of every interval period.
da...@google.com <da...@google.com> #18
ae...@gmail.com <ae...@gmail.com> #19
Branch: androidx-master-dev
commit 25dc21990f5b0d606f3141b9120516b880599b6c
Author: Rahul Ravikumar <rahulrav@google.com>
Date: Mon Apr 29 10:27:18 2019
Add support for initialDelays for PeriodicWorkRequests.
Test: Additional WorkSpecTest unit tests.
Integration tests on API 23, and API 21.
Fixes:
Change-Id: I9eae1c7cf527c231b831f22c6a2d10089d6a63c9
M work/integration-tests/testapp/src/main/java/androidx/work/integration/testapp/MainActivity.java
M work/integration-tests/testapp/src/main/res/layout/activity_main.xml
M work/integration-tests/testapp/src/main/res/values/strings.xml
M work/workmanager/api/2.1.0-alpha01.txt
M work/workmanager/api/current.txt
M work/workmanager/src/androidTest/java/androidx/work/WorkSpecTest.java
M work/workmanager/src/main/java/androidx/work/OneTimeWorkRequest.java
M work/workmanager/src/main/java/androidx/work/WorkRequest.java
M work/workmanager/src/main/java/androidx/work/impl/WorkerWrapper.java
M work/workmanager/src/main/java/androidx/work/impl/background/systemjob/SystemJobScheduler.java
M work/workmanager/src/main/java/androidx/work/impl/model/WorkSpec.java
el...@google.com <el...@google.com>
ae...@gmail.com <ae...@gmail.com> #20
I calculate millis to midnight and schedule a daily backup with PeriodicWorkRequest (should happen each 24h), and it just won't fire up the Worker.
When I remove setInitialDelay() call, PeriodicWorkRequest - it works!
classic
ae...@gmail.com <ae...@gmail.com> #21
Hi. This is still a problem. Should I create new issue about java.lang.IllegalStateException: Cannot perform this operation because there is no current transaction.
or it is going to be fixed in scope of this issue?
This issue is still blocker for my app and there is already 46 days passed since I reported it.
da...@google.com <da...@google.com> #22
Hi - Sorry for the delayed response.
I think you are indeed hitting a different issue with the AndroidSQLiteDriver
, specifically around the
But I am worried that we still have not found the root cause of your original issue with the BundledSQLiteDriver
and the database is locked
, if you could somehow create a sample app (I know it can be hard) that would help us a lot.
I also want to mention a 3rd option for Android and that is not using a SQLiteDriver
with Room which in turn will cause it to default to using SupportSQLite
the underlying SQLite APIs before Room was converted to KMP.
ae...@gmail.com <ae...@gmail.com> #23
Hi. Thank you for your response. For now I am not succeed in reproduce the issue with the BundledSQLiteDriver
and the database is locked
. But I will try more.
Speaking of "not using a SQLiteDriver" - am I understood right that I just need to delete .setDriver()
method?
da...@google.com <da...@google.com> #24
Thats right, not calling setDriver
will make Room work in compatibility mode and will use the FrameworkSQLiteOpenHelper
and its APIs and will keep the 'before KMP coroutines' behavior.
ae...@gmail.com <ae...@gmail.com> #25
So. I removed setDriver
method. The builder is still in common module. Now the error IllegalStateException: Cannot perform this operation because there is no current transaction
happens every time when app trying to make database operation using this code
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()
}
}
The stack trace:
java.lang.IllegalStateException: Cannot perform this operation because there is no current transaction.
at android.database.sqlite.SQLiteSession.throwIfNoTransaction(SQLiteSession.java:1021)
at android.database.sqlite.SQLiteSession.endTransaction(SQLiteSession.java:419)
at android.database.sqlite.SQLiteDatabase.endTransaction(SQLiteDatabase.java:833)
at androidx.sqlite.db.framework.FrameworkSQLiteDatabase.endTransaction(FrameworkSQLiteDatabase.android.kt:100)
at androidx.room.driver.SupportSQLitePooledConnection.transaction(SupportSQLiteConnectionPool.android.kt:90)
at androidx.room.driver.SupportSQLitePooledConnection.access$transaction(SupportSQLiteConnectionPool.android.kt:51)
at androidx.room.driver.SupportSQLitePooledConnection$transaction$1.invokeSuspend(Unknown Source:15)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:98)
at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:113)
at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:89)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:586)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:820)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:717)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:704)
Note: there was AndroidSQLiteDriverPooledConnection
now it is SupportSQLitePooledConnection
in stack trace.
ae...@gmail.com <ae...@gmail.com> #26
Also, users report that when using the Android driver, sometimes the database does not return a response from an SQL query where it should have returned it.
The example of such request
@Query("""SELECT * from "${Holder.TABLE_HOLDER}" WHERE "${Holder.COLUMN_HOLDER_ID}" LIKE :holderId""")
fun getHolderById(holderId: String): Flow<Holder?>
ae...@gmail.com <ae...@gmail.com> #27
I found the way to reproduce it!
First you launch workaroundWithTransaction
method, then getHolderById
method. The result: getHolderById
stops returning result.
This error is ever worse than before because it is reproduceable in almost 100% cases!
I have to return to BundledSQLiteDriver
da...@google.com <da...@google.com> #28
Can you provide more details on the repro case? Is it possible to create a sample repro? Or maybe a test? Can you please show us some code?
Are you starting a transaction and in the transaction you are also collecting the Flow?
db.workaroundWithTransaction {
db.dao.getHolderById(...).collect {
}
}
This is not a valid usage of Flow
because you are essentially starting a transaction that will never end and that might explain the database locked
exception you are seeing.
Here another test I have created based on your description but it works fine for me on all drivers:
@Test
fun check() = runTest {
async(Dispatchers.IO) {
// Insert 100 items in a deferred transaction and notifying invalidation tracker
repeat(100) { id ->
db.useWriterConnection {
it.deferredTransaction {
db.dao().insert(SampleEntity(id.toLong()))
}
}
db.invalidationTracker.refreshAsync()
}
}
async(Dispatchers.IO) {
// Collect list of inserted items until list is of size 100, meaning
// all 100 items where inserted and a result with a list of them was received
db.dao().getItemListFlow().collect {
if (it.size == 100) {
cancel()
}
}
}
}
ae...@gmail.com <ae...@gmail.com> #29
Hi. The order of reproducing:
- call
db.dao().getHolderById("some_id").first()
- will return a result - call
db.useWriterConnection {...}
- to make any change in db - call
db.dao().getHolderById("some_id").first()
- no longer returns a result
Only restarting the app will make db.dao().getHolderById("some_id").first()
work again.
For now I can't create a simple repo, maybe later.
ba...@gmail.com <ba...@gmail.com> #30
I don't have a minimal repro case, but I am facing this issue in my project (
I have been using AndroidSQLiteDriver
in production and never had a database locked crash. Many months ago I briefly deployed BundledSQLiteDriver
but reverted it because of this crash
This weekend I wanted to use window functions on Android so I switched to BundledSQLiteDriver
again. It did not crash on my Pixel 9 Pro during development so I thought the issue was fixed. Then I deployed my changes and am getting tons of crashes again
I then tested on a CAT S22. This thing is a potato and I get database locked crashes easily.
I commented out my transactor.withTransaction
calls so the only transactions are generated by Room and it still crashes
When I use PRAGMA busy_timeout
to increase the timeout then the database just deadlocks instead of crashing
ba...@gmail.com <ba...@gmail.com> #31
Just to add more details:
I can comment out my @RawQuery
, useWriterConnection
, and useReaderConnection
calls, and I still get database locked crashes using only generated @Query
, @Insert
, @Update
, and @Delete
functions. The app runs in a single process
Switching from BundledSQLiteDriver
back to AndroidSQLiteDriver
fixes the issue completely
On my CAT S22 the app crashes on first launch after a clean install 100% of the time. The app will start after relaunching but it will then crash frequently during synchronization
ae...@gmail.com <ae...@gmail.com> #32
Hi. Is there any updates? I believe it is should be P1 issue.
ba...@gmail.com <ba...@gmail.com> #33
My guess, without looking at any of the library code, is that transactions are not being queued with the BundledSQLiteDriver. I have firebase crashes from 20+ different database functions at this point. My pixel 9 pro is probably servicing requests fast enough to not crash, the CAT S22 not so much.
da...@google.com <da...@google.com> #34
I'll grab an old Nexus 5 I have around that is pretty potato to see if I can repro this.
Room has a connection pool manager and it has 4 reader connections and one writer, it uses
ba...@gmail.com <ba...@gmail.com> #35
I became aware of room's connection strategy when I learned that reading data with Room flows acquired a transaction, which was a surprising source of performance problems at my day job 🙃
I thought using AndroidSQLiteDriver
was analogous to not specifying a driver at all, and would use the connection/transaction strategy you mentioned. Based on my observations I assumed this was related to the problem with the BundledSQLiteDriver
- transactions are happening on multiple connections rather than queuing them on one connection? I'm just speculating and could also be mistaken about how this works under the hood.
If you're trying to repro by running my app but aren't having any luck let me know, I could create a branch that seeds the app with some test data or something.
da...@google.com <da...@google.com> #36
I was able to successful run the Tasks app but indeed haven't had luck reproducing the issue, so if you do end up creating that branch with seed data I will gladly use it.
Reading data via a Flow
returned from a @Dao
has never required a transaction, unless specified in the DAO via @Transaction
. Would love to hear more about the surprising performance issues.
However, I agree that transactions tend to be a source of performance issues. If no driver is used Room uses SupportSQLite
and Android's SQLite bindings, transactions there always use the single primary connection and they block each other. When using the AndroidSQLiteDriver
, similarly that uses Android's SQLite binding which will also uses the primary connection. There is a difference in code paths when no driver is specified and when AndroidSQLiteDriver
is used, but it is in terms of backwards compatibility of other SupportSQLite
APIs (see warning in
Now BundledSQLiteDriver
internally does not have a connection pool like the Android driver does and instead relies on Room's which we try to test as much as we can but of course it is not as mature's as Android. So we really appreciate you trying it out and reporting these issues. As for how different it is, the main difference is that the connection pool is suspending, other coroutines can continue while a connection is being used, this is very different from the other drivers that will 'block' the caller which for DAO functions Room alleviates by using a FIFO single threaded pool (the transaction executor) but can't control when other blocking APIs are used (beginTransaction). So yes, it is possible to start multiple transactions with Room's connection pool, but in essence they are also queued via suspending coroutines as the connection is being acquired and returned to the pool.
ba...@gmail.com <ba...@gmail.com> #37
Reading data via a Flow returned from a @Dao has never required a transaction, unless specified in the DAO via @Transaction. Would love to hear more about the surprising performance issues.
The issue we were having was that on startup our sync loop would sometimes start a transaction before our UI created a Room flow, and the UI flow would be blocked until the sync transaction finished. I think we jumped to the conclusion that Room flows acquire a transaction when they're started, but I just looked at the library code again and I think its just acquiring a transaction the first time you observe a table 🤦 edit: OK I'll stop derailing this ticket, but when a flow is started and its the first observer on a table there is a transaction, and when a flow finishes and its the last observer on a table there is a transaction
I was able to successful run the Tasks app but indeed haven't had luck reproducing the issue, so if you do end up creating that branch with seed data I will gladly use it.
I will get this to you ASAP
da...@google.com <da...@google.com> #38
Yes, if a Flow
needs to observe tables that have no observer 'installed' then Room has to create some TRIGGERs to start observing the tables and it does it in a transaction. Unfortunately this has to block the Flow
's initial query to guarantee consistency. I think we would need a different invalidation system, not TRIGGER based, to possibly avoid that start and end transaction but I don't think we have enough strong compelling reasons to change the system.
al...@beeper.com <al...@beeper.com> #39
I have attached a backup file that you can import into Tasks by tapping on 'Settings > Backups > Import' and selecting the file.
On my CAT S22 with BundledSQLiteDriver
it crashes with a database locked error, and the
The next-worst phone I have is a Galaxy S9 and I cannot get the database locked error on there, even with 10x as much data in the database
When I look at Firebase, these are the types of phones experiencing this crash: TP-Link Neffos A5 Tinno Y52 ZTE Blade A34 Moto E13 & E20 Xiamo Redmi A1 & A2 Alcatel 1C Transsion Tecno Spark Go 1 Mobiwire Smart C11
This list is not exhaustive, I just grabbed it from the first 5 distinct crashes. I've never even heard of most of these phones until just now
ae...@gmail.com <ae...@gmail.com> #40
Thank you for participating. I am really glad to see some progress and discussion on this issue.
ap...@google.com <ap...@google.com> #41
Project: platform/frameworks/support
Branch: androidx-main
Author: Daniel Santiago Rivera <
Link:
Reduce no-op transaction while syncing triggers
Expand for full commit details
Reduce no-op transaction while syncing triggers
The ObservedTableStates instance will return a list of observe operations (add or remove triggers) to perform if it 'needs sync'. A sync is required if at least a trigger needs to be added or removed from a table since the last sync. However, it might be that multiple observers are added and removed such that the end result of operations is actually to do nothing. In this case Room still tries to start a database transaction to not add or remove any triggers. Since transactions have lock implications it is best to avoid the transaction that if all observer operations are no-op.
Example case this change is optimizing:
1. Flow A in UI begins collecting, trigger A is installed
2. UI is rotated, not using collectAsStateWithLifecycle() or equivalent
2.a Flow A stops collecting, a sync is required
2.b Flow A starts collecting, a sync is still required
3. Triggers are synced, operation on table A is no-op
Bug: 380088809
Test: Existing
Change-Id: Iae612a1c4f8b8f1e8e15d2f60eb9bf68241570ef
Files:
- M
room/room-runtime/src/commonMain/kotlin/androidx/room/InvalidationTracker.kt
Hash: a0e5f03fe83ec6446228a4b872f1d72fb2bf8216
Date: Thu Jan 23 11:06:08 2025
ae...@gmail.com <ae...@gmail.com> #42
Are you were able to reproduce the issue and fix it or it is an other issue got fixed?
al...@beeper.com <al...@beeper.com> #43
I've spent an hour trying to repro the deadlock I mentioned in PRAGMA busy_timeout = <time in ms>
with the CAT S22. I have not been successful, so maybe that does fix my problem. I'm going to try releasing with BundledSQLiteDriver
again 🤞
ae...@gmail.com <ae...@gmail.com> #44
Hi. Are there any updates on this?
da...@google.com <da...@google.com> #45
Hey - 2.7.0-alpha13 has a change that should reduce the issue, but not guaranteed.
But I was not able to reproduce the issue with the project and data from
Things got busy so I have to dedicate more time to this issue, but its sort of a wild goose chase without a reliable repro.
ck...@gmail.com <ck...@gmail.com> #46
Starting with the latest version, 2.7.0-alpha13, we switched to BundledSQLiteDriver,
which produces hundreds of database-locked exceptions.
Non-fatal Exception: android.database.SQLException: Error code: 5, message: database is locked
at androidx.sqlite.driver.bundled.BundledSQLiteStatementKt.nativeStep(BundledSQLiteStatement.jvmAndroid.kt)
at androidx.sqlite.driver.bundled.BundledSQLiteStatementKt.access$nativeStep(BundledSQLiteStatement.jvmAndroid.kt)
at androidx.sqlite.driver.bundled.BundledSQLiteStatement.step(BundledSQLiteStatement.jvmAndroid.kt:100)
at app.resubs.core.database.dao.PendingNotificationDao_Impl.getAll$lambda$1(PendingNotificationDao_Impl.kt:94)
at androidx.room.util.DBUtil__DBUtil_androidKt$performSuspending$lambda$1$$inlined$internalPerform$1.invokeSuspend(DBUtil.kt:68)
at androidx.room.util.DBUtil__DBUtil_androidKt$performSuspending$lambda$1$$inlined$internalPerform$1.invoke(DBUtil.kt:8)
at androidx.room.util.DBUtil__DBUtil_androidKt$performSuspending$lambda$1$$inlined$internalPerform$1.invoke(DBUtil.kt:4)
at androidx.room.coroutines.ConnectionPoolImpl$useConnection$4.invokeSuspend(ConnectionPoolImpl.kt:144)
at androidx.room.coroutines.ConnectionPoolImpl$useConnection$4.invoke(ConnectionPoolImpl.kt:8)
at androidx.room.coroutines.ConnectionPoolImpl$useConnection$4.invoke(ConnectionPoolImpl.kt:4)
at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:43)
at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:166)
at kotlinx.coroutines.BuildersKt.withContext(Builders.kt)
at androidx.room.coroutines.ConnectionPoolImpl.useConnection(ConnectionPoolImpl.kt:144)
at androidx.room.coroutines.ConnectionPoolImpl$useConnection$1.invokeSuspend(ConnectionPoolImpl.kt:13)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.internal.ScopeCoroutine.afterResume(Scopes.kt:35)
ae...@gmail.com <ae...@gmail.com> #47
Hi
da...@google.com <da...@google.com> #48
I did found that we were not configuring the busy_timeout in the initial connection which can lead to SQLITE_BUSY (error code 5). I've sent a cl to fix that.
I have another alternative / workaround for those with this issue which will also hint me to the root of the cause. In
val actualDriver = BundledSQLiteDriver()
val driverWrapper =
object : SQLiteDriver by actualDriver {
override fun open(fileName: String): SQLiteConnection {
return actualDriver.open(fileName).also { newConnection ->
newConnection.execSQL("PRAGMA busy_timeout = $customBusyTimeout")
}
}
}
roomDatabaseBuilder
.setDriver(driverWrapper)
Let me know if this helps or not.
ae...@gmail.com <ae...@gmail.com> #49
Hi
ap...@google.com <ap...@google.com> #50
Project: platform/frameworks/support
Branch: androidx-main
Author: Daniel Santiago Rivera <
Link:
Apply busy_timeout config for initial connection
Expand for full commit details
Apply busy_timeout config for initial connection
Fix an issue where busy_timeout was not being configured in the initial connection where schema validation is also done. The busy_timeout must be set on all connections to avoid SQLITE_BUSY.
Bug: 380088809
Test: BaseBuilderTest#setCustomBusyTimeout
Change-Id: I9320856f64363b05bcf6407eed0efe36ef3312a3
Files:
- M
room/integration-tests/multiplatformtestapp/src/commonTest/kotlin/androidx/room/integration/multiplatformtestapp/test/BaseBuilderTest.kt
- M
room/room-runtime/src/commonMain/kotlin/androidx/room/RoomConnectionManager.kt
- M
room/room-runtime/src/commonMain/kotlin/androidx/room/coroutines/ConnectionPool.kt
Hash: ba379355137898cf40a16bff549863ab6a55f093
Date: Mon Feb 10 09:32:51 2025
ae...@gmail.com <ae...@gmail.com> #51
Hi. I have applied this fix to my app and release for 10% of users. I got 4000 installs and for now I don't see this error. I am going to try with version 2.7.0-rc01.
se...@scrapgolem.com <se...@scrapgolem.com> #52
I'm still seeing this or a similar issue on 2.7.0-rc01. I haven't tried using AndroidSQLiteDriver
or any of the other workarounds listed here. Previously, I was using setQueryCoroutineContext(Dispatchers.IO.limitedParallelism(1))
which did solve the problem. I removed that after upgrading to 2.7.0-rc01.
I got this crash yesterday:
android.database.SQLException: Error code: 5, message: database is locked
at androidx.sqlite.driver.bundled.BundledSQLiteStatementKt.nativeStep(SourceFile)
at androidx.sqlite.driver.bundled.BundledSQLiteStatementKt.access$nativeStep(BundledSQLiteStatement.jvmAndroid.kt:0)
at androidx.sqlite.driver.bundled.BundledSQLiteStatement.step(BundledSQLiteStatement.jvmAndroid.kt:0)
at androidx.sqlite.driver.bundled.BundledSQLiteStatement.step(BundledSQLiteStatement.jvmAndroid.kt:100)
at androidx.sqlite.SQLite.execSQL(com.google.android.gms:play-services-mlkit-barcode-scanning@@18.3.1:56)
at androidx.room.coroutines.PooledConnectionImpl.endTransaction(ConnectionPoolImpl.kt:420)
at androidx.room.coroutines.PooledConnectionImpl.transaction(ConnectionPoolImpl.kt:388)
at androidx.room.coroutines.PooledConnectionImpl.isRecycled(ConnectionPoolImpl.kt:0)
at androidx.room.coroutines.PooledConnectionImpl.access$isRecycled(ConnectionPoolImpl.kt:0)
at androidx.room.coroutines.PooledConnectionImpl.withTransaction(ConnectionPoolImpl.kt:0)
at androidx.room.coroutines.PooledConnectionImpl.withTransaction(ConnectionPoolImpl.kt:344)
at kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsKt.getCOROUTINE_SUSPENDED
at androidx.room.util.DBUtil__DBUtil_androidKt$performInTransactionSuspending$3$invokeSuspend$$inlined$internalPerform$1.invokeSuspend(DBUtil.kt:0)
at androidx.room.util.DBUtil__DBUtil_androidKt$performInTransactionSuspending$3$invokeSuspend$$inlined$internalPerform$1.invokeSuspend(DBUtil.kt:59)
at androidx.room.util.DBUtil__DBUtil_androidKt$performInTransactionSuspending$3$invokeSuspend$$inlined$internalPerform$1.invoke(DBUtil.kt:0)
at androidx.room.util.DBUtil__DBUtil_androidKt$performInTransactionSuspending$3$invokeSuspend$$inlined$internalPerform$1.invoke(DBUtil.kt:0)
at kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsKt.getCOROUTINE_SUSPENDED
at androidx.room.coroutines.ConnectionPoolImpl$useConnection$4.invokeSuspend(ConnectionPoolImpl.kt:0)
at androidx.room.coroutines.ConnectionPoolImpl$useConnection$4.invokeSuspend(ConnectionPoolImpl.kt:144)
at androidx.room.coroutines.ConnectionPoolImpl$useConnection$4.invoke(ConnectionPoolImpl.kt:0)
at androidx.room.coroutines.ConnectionPoolImpl$useConnection$4.invoke(ConnectionPoolImpl.kt:0)
at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(ChildStackFactory.kt:43)
at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext
at kotlinx.coroutines.BuildersKt.withContext(DebugStrings.kt:0)
at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext
at kotlinx.coroutines.BuildersKt.withContext(DebugStrings.kt:1)
at androidx.room.coroutines.ConnectionPoolImpl.useConnection(ConnectionPoolImpl.kt:144)
at androidx.room.RoomDatabase.useConnection$room_runtime_release(RoomDatabase.android.kt:0)
at androidx.room.RoomConnectionManager.useConnection
at androidx.room.RoomDatabase.useConnection$room_runtime_release(RoomDatabase.android.kt:587)
at kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsKt.getCOROUTINE_SUSPENDED
at androidx.room.util.DBUtil__DBUtil_androidKt$performInTransactionSuspending$3.invokeSuspend(DBUtil.android.kt:0)
at androidx.room.util.DBUtil__DBUtil_androidKt$performInTransactionSuspending$3.invokeSuspend(DBUtil.android.kt:243)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:0)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:100)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
at java.lang.Thread.run(Thread.java:1012)
ae...@gmail.com <ae...@gmail.com> #53
Hi. I got a new error: Fatal Exception: android.database.SQLException: Error code: 5, message: Timed out attempting to acquire a reader connection.
Writer pool:
Xu1@d088033 (capacity=1)
[1] - ow@e204ff0
Status: Free connection
Reader pool:
Xu1@6c0ec8f (capacity=4)
[1] - ow@dd27b1c
Status: Acquired connection
Coroutine: [go2@7c92325, eo2{Active}@cf76cfa, Dispatchers.IO]
Acquired:
at lR.C(Unknown Source:310)
at iR.invokeSuspend(Unknown Source:13)
at dq.resumeWith(Unknown Source:8)
at TR1.o(Unknown Source:6)
at W.resumeWith(Unknown Source:22)
at dq.resumeWith(Unknown Source:31)
at xc0.run(Unknown Source:109)
at K2.run(Unknown Source:1024)
at qc2.run(Unknown Source:2)
at SV.run(Unknown Source:93)
[2] - ow@71a2d08
Status: Free connection
[3] - ow@c0dcca1
Status: Free connection
[4] - ow@bbf5ec6
Status: Free connection
da...@google.com <da...@google.com> #54
"Timed out attempting to acquire a reader connection" is a better error than "database is locked", hehe
It seems you have 3 zombie connections in your pool. I suspect this is because currently don't refill the pool when a connection dies. I'll work on a change to make sure the pool is always of the correct size. Thanks again for your patience on helping us make the library better.
ap...@google.com <ap...@google.com> #55
Project: platform/frameworks/support
Branch: androidx-main
Author: Daniel Santiago Rivera <
Link:
Reimplement suspending pool with Semaphore
Expand for full commit details
Reimplement suspending pool with Semaphore
This changes the implementation of Room's connection pool to use a Semaphore instead of a Channel. It makes the implementation simpler and removes the possibility of connections getting 'lost' due the the various branches needed to handle when a channel send / receive fails.
The Channel was also used as a 'queue' instead a circular array is used to push and pop connections acquired and released into the pool. The semaphore still controls the amount of connections being locked and unlocked and is the suspending API that waits for a connection to be free.
Bug: 322386871
Bug: 380088809
Test: BaseConnectionPoolTest
Change-Id: I9b7f2d44b511eb3e3d8cdaf8cb8905bb6203f8c5
Files:
- M
room/room-runtime/src/commonMain/kotlin/androidx/room/coroutines/ConnectionPoolImpl.kt
- M
room/room-runtime/src/commonTest/kotlin/androidx/room/coroutines/BaseConnectionPoolTest.kt
Hash: dc4715197f7869c87af3025acba91a0c8a57db4d
Date: Mon Mar 17 12:01:10 2025
da...@google.com <da...@google.com> #56
The next release (2.7.0-rc03
) will have a change that should alleviate the 'Timed out attempting to acquire a reader connection
' issue, I'll continue to keep this issue open so others can report if they are still experiencing it or not.
ae...@gmail.com <ae...@gmail.com> #57
Hi. Thank you for your fixes. I have released 2.7.0-rc01
for 100% of users. For now it have about 22000 installs and I don't see the error SQLException: Error code: 5, message: database is locked
anymore.
ae...@gmail.com <ae...@gmail.com> #58
Hi. Got 1 android.database.SQLException: Error code: 5, message: database is locked
RoomDB: 2.7.0-rc03. Device: Oppo, Android 11
Note: before this was at native step, now I got it at nativePrepare.
Fatal Exception: android.database.SQLException: Error code: 5, message: database is locked
at androidx.sqlite.driver.bundled.BundledSQLiteConnectionKt.nativePrepare(BundledSQLiteConnection.jvmAndroid.kt)
at androidx.sqlite.driver.bundled.BundledSQLiteConnectionKt.access$nativePrepare(BundledSQLiteConnection.jvmAndroid.kt)
at androidx.sqlite.driver.bundled.BundledSQLiteConnection.prepare(BundledSQLiteConnection.jvmAndroid.kt:36)
at androidx.sqlite.SQLite.execSQL(SQLite.java:56)
at androidx.room.BaseRoomConnectionManager.configureSynchronousFlag(BaseRoomConnectionManager.java:156)
at androidx.room.BaseRoomConnectionManager.configurationConnection(BaseRoomConnectionManager.java:135)
at androidx.room.BaseRoomConnectionManager.access$configurationConnection(BaseRoomConnectionManager.java:36)
at androidx.room.BaseRoomConnectionManager$DriverWrapper.openLocked$lambda$1(BaseRoomConnectionManager.java:83)
at androidx.room.concurrent.ExclusiveLock.withLock(ExclusiveLock.java:50)
at androidx.room.BaseRoomConnectionManager$DriverWrapper.openLocked(BaseRoomConnectionManager.java:65)
at androidx.room.BaseRoomConnectionManager$DriverWrapper.open(BaseRoomConnectionManager.java:57)
at androidx.room.coroutines.ConnectionPoolImpl._init_$lambda$4(ConnectionPoolImpl.java:85)
at androidx.room.coroutines.Pool.tryOpenNewConnectionLocked(ConnectionPoolImpl.kt:234)
at androidx.room.coroutines.Pool.acquire(ConnectionPoolImpl.kt:219)
at androidx.room.coroutines.ConnectionPoolImpl$acquireWithTimeout$2.invokeSuspend(ConnectionPoolImpl.kt:171)
at androidx.room.coroutines.ConnectionPoolImpl$acquireWithTimeout$2.invoke(ConnectionPoolImpl.kt:12)
at androidx.room.coroutines.ConnectionPoolImpl$acquireWithTimeout$2.invoke(ConnectionPoolImpl.kt:12)
at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturnIgnoreTimeout(Undispatched.kt:54)
at kotlinx.coroutines.TimeoutKt.setupTimeout(Timeout.kt:149)
at kotlinx.coroutines.TimeoutKt.withTimeout(Timeout.kt:44)
at kotlinx.coroutines.TimeoutKt.withTimeout-KLykuaI(Timeout.kt:72)
at androidx.room.coroutines.ConnectionPoolImpl.useConnection(ConnectionPoolImpl.kt:542)
at androidx.room.RoomConnectionManager.useConnection(RoomConnectionManager.java:126)
at androidx.room.RoomDatabase.useConnection$room_runtime_release(RoomDatabase.android.kt:588)
at androidx.room.util.DBUtil__DBUtil_androidKt$performSuspending$$inlined$compatCoroutineExecute$DBUtil__DBUtil_androidKt$1.invokeSuspend(DBUtil.android.kt:109)
at androidx.room.util.DBUtil__DBUtil_androidKt$performSuspending$$inlined$compatCoroutineExecute$DBUtil__DBUtil_androidKt$1.invoke(DBUtil.android.kt:12)
at androidx.room.util.DBUtil__DBUtil_androidKt$performSuspending$$inlined$compatCoroutineExecute$DBUtil__DBUtil_androidKt$1.invoke(DBUtil.android.kt:12)
at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:43)
at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(BuildersKt__Builders_common.kt:166)
at kotlinx.coroutines.BuildersKt.withContext(Builders.kt:1)
at androidx.room.util.DBUtil__DBUtil_androidKt.performSuspending(DBUtil__DBUtil_android.kt:247)
at androidx.room.util.DBUtil.performSuspending(DBUtil.java:1)
at androidx.room.coroutines.FlowUtil$createFlow$$inlined$map$1$2.emit(Emitters.kt:224)
at kotlinx.coroutines.flow.FlowKt__ChannelsKt.emitAllImpl$FlowKt__ChannelsKt(FlowKt__Channels.kt:33)
at kotlinx.coroutines.flow.FlowKt__ChannelsKt.access$emitAllImpl$FlowKt__ChannelsKt(FlowKt__Channels.kt:1)
at kotlinx.coroutines.flow.FlowKt__ChannelsKt$emitAllImpl$1.invokeSuspend(Channels.kt:11)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:100)
at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.java:113)
at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:89)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.java:586)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:820)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:717)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:704)
ae...@gmail.com <ae...@gmail.com> #59
I also got 1 exception: android.database.SQLException: Error code: 5, message: Timed out attempting to acquire a writer connection.
Fatal Exception: android.database.SQLException: Error code: 5, message: Timed out attempting to acquire a writer connection.
Writer pool:
fv1@6e0810d (capacity=1, permits=0, queue=(size=0)[], )
[1] - Aw@1f718c2
Status: Acquired connection
Coroutine: [Ac0{Active}@7ccd6d3, Dispatchers.IO]
Acquired:
at xR.C(Unknown Source:328)
at iK1.w(Unknown Source:6)
at il2.h(Unknown Source:77)
at Wk2.invokeSuspend(Unknown Source:28)
at pq.resumeWith(Unknown Source:8)
at Bc0.run(Unknown Source:109)
at K2.run(Unknown Source:1024)
at wc2.run(Unknown Source:2)
at fW.run(Unknown Source:93)
Reader pool:
fv1@7a12109 (capacity=4, permits=4, queue=(size=0)[], )
[1] - null
[2] - null
[3] - null
[4] - null
at androidx.sqlite.SQLite.throwSQLiteException(SQLite.java:67)
at androidx.room.coroutines.ConnectionPoolImpl.throwTimeoutException(ConnectionPoolImpl.kt:191)
at androidx.room.coroutines.ConnectionPoolImpl.useConnection(ConnectionPoolImpl.kt:142)
at androidx.room.coroutines.ConnectionPoolImpl$useConnection$1.invokeSuspend(ConnectionPoolImpl.kt:13)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.internal.ScopeCoroutine.afterResume(Scopes.kt:35)
at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:101)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:98)
at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.java:113)
at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:89)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.java:586)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:820)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:717)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:704)
ae...@gmail.com <ae...@gmail.com> #60
And also I got 36 java.lang.UnsatisfiedLinkError: dlopen failed: library "libsqliteJni.so" not found
Maybe it may be linked with nativePrepare error?
Fatal Exception: java.lang.UnsatisfiedLinkError: dlopen failed: library "libsqliteJni.so" not found
at java.lang.Runtime.loadLibrary0(Runtime.java:1131)
at java.lang.Runtime.loadLibrary0(Runtime.java:1051)
at java.lang.System.loadLibrary(System.java:1664)
at androidx.sqlite.driver.bundled.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:21)
at androidx.sqlite.driver.bundled.BundledSQLiteDriver$NativeLibraryObject.<clinit>(BundledSQLiteDriver.jvmAndroid.kt:62)
at androidx.sqlite.driver.bundled.BundledSQLiteDriver.open(BundledSQLiteDriver.java:55)
at androidx.sqlite.driver.bundled.BundledSQLiteDriver.open(BundledSQLiteDriver.java:42)
at androidx.room.BaseRoomConnectionManager$DriverWrapper.openLocked$lambda$1(BaseRoomConnectionManager.java:72)
at androidx.room.concurrent.ExclusiveLock.withLock(ExclusiveLock.java:50)
at androidx.room.BaseRoomConnectionManager$DriverWrapper.openLocked(BaseRoomConnectionManager.java:65)
at androidx.room.BaseRoomConnectionManager$DriverWrapper.open(BaseRoomConnectionManager.java:57)
at androidx.room.coroutines.ConnectionPoolImpl._init_$lambda$5(ConnectionPoolImpl.java:92)
at androidx.room.coroutines.Pool.tryOpenNewConnectionLocked(ConnectionPoolImpl.kt:234)
at androidx.room.coroutines.Pool.acquire(ConnectionPoolImpl.kt:219)
at androidx.room.coroutines.ConnectionPoolImpl$acquireWithTimeout$2.invokeSuspend(ConnectionPoolImpl.kt:171)
at androidx.room.coroutines.ConnectionPoolImpl$acquireWithTimeout$2.invoke(ConnectionPoolImpl.kt:12)
at androidx.room.coroutines.ConnectionPoolImpl$acquireWithTimeout$2.invoke(ConnectionPoolImpl.kt:12)
at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturnIgnoreTimeout(Undispatched.kt:54)
at kotlinx.coroutines.TimeoutKt.setupTimeout(Timeout.kt:149)
at kotlinx.coroutines.TimeoutKt.withTimeout(Timeout.kt:44)
at kotlinx.coroutines.TimeoutKt.withTimeout-KLykuaI(Timeout.kt:72)
at androidx.room.coroutines.ConnectionPoolImpl.useConnection(ConnectionPoolImpl.kt:542)
at androidx.room.RoomConnectionManager.useConnection(RoomConnectionManager.java:126)
at androidx.room.RoomDatabase.useConnection$room_runtime_release(RoomDatabase.android.kt:588)
at androidx.room.TriggerBasedInvalidationTracker.syncTriggers$room_runtime_release(InvalidationTracker.kt:300)
at androidx.room.TriggerBasedInvalidationTracker$createFlow$1$1.invokeSuspend(InvalidationTracker.kt:233)
at androidx.room.TriggerBasedInvalidationTracker$createFlow$1$1.invoke(InvalidationTracker.kt:12)
at androidx.room.TriggerBasedInvalidationTracker$createFlow$1$1.invoke(InvalidationTracker.kt:12)
at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:43)
at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(BuildersKt__Builders_common.kt:166)
at kotlinx.coroutines.BuildersKt.withContext(Builders.kt:1)
at androidx.room.TriggerBasedInvalidationTracker$createFlow$1.invokeSuspend(InvalidationTracker.kt:233)
at androidx.room.TriggerBasedInvalidationTracker$createFlow$1.invoke(InvalidationTracker.kt:12)
at androidx.room.TriggerBasedInvalidationTracker$createFlow$1.invoke(InvalidationTracker.kt:12)
at kotlinx.coroutines.flow.SafeFlow.collectSafely(SafeFlow.java:57)
at kotlinx.coroutines.flow.AbstractFlow.collect(AbstractFlow.java:226)
at kotlinx.coroutines.flow.internal.ChannelFlowOperatorImpl.flowCollect(ChannelFlow.kt:191)
at kotlinx.coroutines.flow.internal.ChannelFlowOperator.collectTo$suspendImpl(ChannelFlow.kt:153)
at kotlinx.coroutines.flow.internal.ChannelFlowOperator.collectTo(ChannelFlow.kt:5)
at kotlinx.coroutines.flow.internal.ChannelFlow$collectToFun$1.invokeSuspend(ChannelFlow.kt:56)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:100)
at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.java:113)
at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:89)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.java:586)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:820)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:717)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:704)
ae...@gmail.com <ae...@gmail.com> #61
Hi. I also got timeout exception in iOS app.
OS Version: iPhone OS 17.5.1 (21F90)
Release Type: User
Baseband Version: 5.00.00
Report Version: 104
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Termination Reason: SIGNAL 6 Abort trap: 6
Terminating Process: MyApp [5748]
Triggered by Thread: 33
Last Exception Backtrace:
0 MyApp 0x106543a60 kfun:androidx.sqlite#throwSQLiteException(kotlin.Int;kotlin.String?){}kotlin.Nothing + 692 (SQLite.kt:67)
1 MyApp 0x10655d49c kfun:androidx.room.coroutines.ConnectionPoolImpl.throwTimeoutException#internal + 508 (ConnectionPoolImpl.kt:191)
2 MyApp 0x10655cdf0 kfun:androidx.room.coroutines.ConnectionPoolImpl.$useConnectionCOROUTINE$2.invokeSuspend#internal + 5996 (ConnectionPoolImpl.kt:142)
3 MyApp 0x104ed438c kfun:kotlin.coroutines.native.internal.BaseContinuationImpl#invokeSuspend(kotlin.Result<kotlin.Any?>){}kotlin.Any?-trampoline + 28 (ContinuationImpl.kt:50)
4 MyApp 0x104ed438c <inlined-lambda> + 44 (ContinuationImpl.kt:30)
5 MyApp 0x104ed438c kfun:kotlin#with(0:0;kotlin.Function1<0:0,0:1>){0§<kotlin.Any?>;1§<kotlin.Any?>}0:1 + 44 (Standard.kt:70)
6 MyApp 0x104ed438c kfun:kotlin.coroutines.native.internal.BaseContinuationImpl#resumeWith(kotlin.Result<kotlin.Any?>){} + 188 (ContinuationImpl.kt:26)
7 MyApp 0x105133c1c kfun:kotlin.coroutines.Continuation#resumeWith(kotlin.Result<1:0>){}-trampoline + 284 (Continuation.kt:26)
8 MyApp 0x105133c1c kfun:kotlinx.coroutines.internal.ScopeCoroutine#afterResume(kotlin.Any?){} + 404 (Scopes.kt:35)
9 MyApp 0x1050cb19c kfun:kotlinx.coroutines.AbstractCoroutine#afterResume(kotlin.Any?){}-trampoline + 28 (AbstractCoroutine.kt:113)
10 MyApp 0x1050cb19c kfun:kotlinx.coroutines.AbstractCoroutine#resumeWith(kotlin.Result<1:0>){} + 232 (AbstractCoroutine.kt:101)
11 MyApp 0x104ed4590 kfun:kotlin.coroutines.Continuation#resumeWith(kotlin.Result<1:0>){}-trampoline + 288 (Continuation.kt:26)
12 MyApp 0x104ed4590 <inlined-lambda> + 364 (ContinuationImpl.kt:43)
13 MyApp 0x104ed4590 kfun:kotlin#with(0:0;kotlin.Function1<0:0,0:1>){0§<kotlin.Any?>;1§<kotlin.Any?>}0:1 + 364 (Standard.kt:70)
14 MyApp 0x104ed4590 kfun:kotlin.coroutines.native.internal.BaseContinuationImpl#resumeWith(kotlin.Result<kotlin.Any?>){} + 704 (ContinuationImpl.kt:26)
15 MyApp 0x10512ef60 <inlined-lambda> + 2412 (Continuation.kt:0)
16 MyApp 0x10512ef60 kfun:kotlinx.coroutines#withContinuationContext(kotlin.coroutines.Continuation<*>;kotlin.Any?;kotlin.Function0<0:0>){0§<kotlin.Any?>}0:0 + 2412 (CoroutineContext.kt:44)
17 MyApp 0x10512ef60 kfun:kotlinx.coroutines.DispatchedTask#run(){} + 2632 (DispatchedTask.kt:82)
18 MyApp 0x1051311d0 kfun:kotlinx.coroutines.Runnable#run(){}-trampoline + 276 (Runnable.kt:12)
19 MyApp 0x1051311d0 kfun:kotlinx.coroutines.internal.LimitedDispatcher.Worker.run#internal + 416 (LimitedDispatcher.kt:124)
20 MyApp 0x10514d8e0 kfun:kotlinx.coroutines.Runnable#run(){}-trampoline + 52 (Runnable.kt:12)
21 MyApp 0x10514d8e0 kfun:kotlinx.coroutines.MultiWorkerDispatcher.MultiWorkerDispatcher$workerRunLoop$1.$invokeCOROUTINE$0.invokeSuspend#internal + 2232 (MultithreadedDispatchers.kt:116)
22 MyApp 0x104ed438c kfun:kotlin.coroutines.native.internal.BaseContinuationImpl#invokeSuspend(kotlin.Result<kotlin.Any?>){}kotlin.Any?-trampoline + 28 (ContinuationImpl.kt:50)
23 MyApp 0x104ed438c <inlined-lambda> + 44 (ContinuationImpl.kt:30)
24 MyApp 0x104ed438c kfun:kotlin#with(0:0;kotlin.Function1<0:0,0:1>){0§<kotlin.Any?>;1§<kotlin.Any?>}0:1 + 44 (Standard.kt:70)
25 MyApp 0x104ed438c kfun:kotlin.coroutines.native.internal.BaseContinuationImpl#resumeWith(kotlin.Result<kotlin.Any?>){} + 188 (ContinuationImpl.kt:26)
26 MyApp 0x10512ecdc kfun:kotlin.coroutines.Continuation#resumeWith(kotlin.Result<1:0>){}-trampoline + 24 (Continuation.kt:26)
27 MyApp 0x10512ecdc kfun:kotlin.coroutines#resume__at__kotlin.coroutines.Continuation<0:0>(0:0){0§<kotlin.Any?>} + 24 (Continuation.kt:45)
28 MyApp 0x10512ecdc <inlined-lambda> + 1768 (DispatchedTask.kt:100)
29 MyApp 0x10512ecdc kfun:kotlinx.coroutines#withContinuationContext(kotlin.coroutines.Continuation<*>;kotlin.Any?;kotlin.Function0<0:0>){0§<kotlin.Any?>}0:0 + 1768 (CoroutineContext.kt:44)
30 MyApp 0x10512ecdc kfun:kotlinx.coroutines.DispatchedTask#run(){} + 1988 (DispatchedTask.kt:82)
31 MyApp 0x1050ddf68 kfun:kotlinx.coroutines.Runnable#run(){}-trampoline + 284 (Runnable.kt:12)
32 MyApp 0x1050ddf68 <inlined-lambda> + 284 (EventLoop.common.kt:263)
33 MyApp 0x1050ddf68 <inlined-lambda> + 284 (Dispatchers.kt:104)
34 MyApp 0x1050ddf68 kfun:kotlinx.cinterop#autoreleasepool(kotlin.Function0<0:0>){0§<kotlin.Any?>}0:0 + 292 (ObjectiveCUtils.kt:13)
35 MyApp 0x1050ddf68 kfun:kotlinx.coroutines#platformAutoreleasePool(kotlin.Function0<kotlin.Unit>){} + 292 (Dispatchers.kt:104)
36 MyApp 0x1050ddf68 kfun:kotlinx.coroutines.EventLoopImplBase#processNextEvent(){}kotlin.Long + 1216 (EventLoop.common.kt:263)
37 MyApp 0x105144da4 kfun:kotlinx.coroutines.EventLoop#processNextEvent(){}kotlin.Long-trampoline + 20 (EventLoop.common.kt:49)
38 MyApp 0x105144da4 kfun:kotlinx.coroutines.BlockingCoroutine.joinBlocking#internal + 144 (Builders.kt:131)
39 MyApp 0x105144da4 kfun:kotlinx.coroutines#runBlocking(kotlin.coroutines.CoroutineContext;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.CoroutineScope,0:0>){0§<kotlin.Any?>}0:0 + 1836 (Builders.kt:70)
40 MyApp 0x10514ca98 kfun:kotlinx.coroutines#runBlocking$default(kotlin.coroutines.CoroutineContext?;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.CoroutineScope,0:0>;kotlin.Int){0§<kotlin.Any?>}0:0 + 12 (Builders.kt:47)
41 MyApp 0x10514ca98 kfun:kotlinx.coroutines.MultiWorkerDispatcher.workerRunLoop#internal + 156 (MultithreadedDispatchers.kt:102)
42 MyApp 0x10514ca98 kfun:kotlinx.coroutines.MultiWorkerDispatcher.MultiWorkerDispatcher$1.MultiWorkerDispatcher$1$invoke$$inlined$apply$1.invoke#internal + 164 (MultithreadedDispatchers.kt:86)
43 MyApp 0x10514ca98 kfun:kotlinx.coroutines.MultiWorkerDispatcher.MultiWorkerDispatcher$1.MultiWorkerDispatcher$1$invoke$$inlined$apply$1.$<bridge-DNN>invoke(){}#internal + 208 (MultithreadedDispatchers.kt:86)
44 MyApp 0x10a0c9064 Worker::processQueueElement(bool) + 2296
45 MyApp 0x10a0c86b4 (anonymous namespace)::workerRoutine(void*) + 128
46 libsystem_pthread.dylib 0x1ea79506c _pthread_start + 136 (pthread.c:931)
47 libsystem_pthread.dylib 0x1ea7900d8 thread_start + 8 (:-1)
da...@google.com <da...@google.com> #62
The time out happens after
Note that if you have a big operation you could use CoroutineName
to give a name to the coroutine to further help debug which coroutine has the connection as that will show up in the exception message.
ae...@gmail.com <ae...@gmail.com> #63
Hi. Thank you for your answer. I will think about using CoroutineName
for my scopes.
Could android.database.SQLException: Error code: 5, message: Timed out attempting to acquire a writer connection
be linked with timeout exception?
Description
Component used: RoomDB
Version used: Room - 2.7.0-alpha11, sqlite-bundled - 2.5.0-alpha11
Devices/Android versions reproduced on: Transsion Tecno, Nokia C21 Plus, Redmi A1+. Android 11-14.
Crash stack:
Please fix it.