I'm trying to get Exposed txns to work with kotlin...
# exposed
I'm trying to get Exposed txns to work with kotlinx.coroutines. I start many txns in parallel using launch. This shouldn't be a problem - as long as I don't access one txn from multiple threads, right? The following code results in many
SQLTransientConnectionException: HikariPool-1 - Connection is not available, request timed out after 30012ms.
I have a connection pool. Once the thread limit is reached, all connections hang at the INSERT statement until the exceptions are thrown after some delay. The println is never reached for these txns.
Copy code
coroutineScope {
    repeat(200) { i ->
        launch {
            newSuspendedTransaction(context = <http://Dispatchers.IO|Dispatchers.IO>) { // works fine if context parameter is null (or left out)
                suspendedTransaction {
                    TestTable.insert { ... }
            println("$i done")
The code works however, if I remove the parameter
from the
function call. Am I misunderstanding the capabilities of suspended txns? What do I have to change to make this code run as expected?