diff --git a/exposed-jdbc/src/main/kotlin/org/jetbrains/exposed/v1/jdbc/transactions/experimental/Suspended.kt b/exposed-jdbc/src/main/kotlin/org/jetbrains/exposed/v1/jdbc/transactions/experimental/Suspended.kt index ffa46ca3f5..9ac2b45e86 100644 --- a/exposed-jdbc/src/main/kotlin/org/jetbrains/exposed/v1/jdbc/transactions/experimental/Suspended.kt +++ b/exposed-jdbc/src/main/kotlin/org/jetbrains/exposed/v1/jdbc/transactions/experimental/Suspended.kt @@ -165,7 +165,11 @@ private suspend fun withTransactionScope( val newContext = context ?: coroutineContext - return TransactionScope(tx, newContext + element).body() + return try { + TransactionScope(tx, newContext + element).body() + } finally { + manager.bindTransactionToThread(null) // remove the transaction from the ThreadLocal + } } val sameTransaction = currentScope?.holdsSameTransaction(currentTransaction) == true