https://kotlinlang.org logo
a

Animesh Sahu

11/27/2019, 8:49 AM
------------------------------------------------------------------------------------ Another question: I am getting when consuming the data (select statement) using forEach()
Copy code
Exception in thread "DefaultDispatcher-worker-7 @coroutine#49" org.sqlite.SQLiteException: [SQLITE_BUSY]  The database file is locked (database is locked)
	at org.sqlite.core.DB.newSQLException(DB.java:941)
	at org.sqlite.core.DB.newSQLException(DB.java:953)
	at org.sqlite.core.DB.throwex(DB.java:918)
	at org.sqlite.core.DB.exec(DB.java:178)
	at org.sqlite.SQLiteConnection.commit(SQLiteConnection.java:404)
	at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManager$ThreadLocalTransaction.commit(ThreadLocalTransactionManager.kt:57)
	at org.jetbrains.exposed.sql.Transaction.commit(Transaction.kt:66)
	at org.jetbrains.exposed.sql.transactions.experimental.SuspendedKt.commitInAsync(Suspended.kt:103)
	at org.jetbrains.exposed.sql.transactions.experimental.SuspendedKt.access$commitInAsync(Suspended.kt:1)
	at org.jetbrains.exposed.sql.transactions.experimental.SuspendedKt$suspendedTransactionAsyncInternal$1.invokeSuspend(Suspended.kt:168)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:241)
	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:594)
	at kotlinx.coroutines.scheduling.CoroutineScheduler.access$runSafely(CoroutineScheduler.kt:60)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:740)
t

tapac

11/27/2019, 10:04 AM
I guess you have to enable multi-thread mode in SQLite to work with asyncs. https://www.sqlite.org/threadsafe.html
a

Animesh Sahu

11/29/2019, 4:29 PM
@tapac I didn't do anything, i'm just executing a simple stmt, using
newSuspendedTransaction()
i.e. coroutine dispatching into the
<http://Dispatchers.IO|Dispatchers.IO>
thread. What's going wrong?
t

tapac

11/30/2019, 8:39 AM
Do you have outer
transaction
block or maybe you run multiple
newSuspendedTransaction
?
a

Animesh Sahu

11/30/2019, 8:40 AM
Only the newSuspendedTransaction {}
I have one of them per call but maybe coroutine executing them in parallel!?
👌 1