Animesh Sahu

    Animesh Sahu

    2 years ago
    ------------------------------------------------------------------------------------ Another question: I am getting when consuming the data (select statement) using forEach()
    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)
    tapac

    tapac

    2 years ago
    I guess you have to enable multi-thread mode in SQLite to work with asyncs. https://www.sqlite.org/threadsafe.html
    Animesh Sahu

    Animesh Sahu

    2 years ago
    @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?
    tapac

    tapac

    2 years ago
    Do you have outer
    transaction
    block or maybe you run multiple
    newSuspendedTransaction
    ?
    Animesh Sahu

    Animesh Sahu

    2 years ago
    Only the newSuspendedTransaction {}
    I have one of them per call but maybe coroutine executing them in parallel!?