mirror of
https://github.com/corda/corda.git
synced 2025-01-12 07:52:38 +00:00
* CORDA-1790 Roll back flow transaction on exception * CORDA-1790 Roll back flow transaction on exception * CORDA-1790 Roll back flow transaction on exception
This commit is contained in:
parent
ac6cbeca0c
commit
729d1b29a6
@ -147,6 +147,19 @@ class FlowStateMachineImpl<R>(override val id: StateMachineRunId,
|
||||
}
|
||||
}
|
||||
|
||||
internal fun rollbackTransaction() {
|
||||
val transaction = contextTransaction
|
||||
try {
|
||||
logger.trace { "Rolling back transaction $transaction on ${Strand.currentStrand()}." }
|
||||
transaction.rollback()
|
||||
} catch (e: SQLException) {
|
||||
logger.error("Transaction rollback failed: ${e.message}", e)
|
||||
System.exit(1)
|
||||
} finally {
|
||||
transaction.close()
|
||||
}
|
||||
}
|
||||
|
||||
@Suspendable
|
||||
override fun initiateFlow(otherParty: Party, sessionFlow: FlowLogic<*>): FlowSession {
|
||||
val sessionKey = Pair(sessionFlow, otherParty)
|
||||
|
@ -452,10 +452,14 @@ class StateMachineManagerImpl(
|
||||
}
|
||||
endAllFiberSessions(fiber, result, propagated)
|
||||
} finally {
|
||||
fiber.commitTransaction()
|
||||
if (result.isSuccess) {
|
||||
fiber.commitTransaction()
|
||||
totalFinishedFlows.inc()
|
||||
unfinishedFibers.countDown()
|
||||
} else {
|
||||
fiber.rollbackTransaction()
|
||||
}
|
||||
decrementLiveFibers()
|
||||
totalFinishedFlows.inc()
|
||||
unfinishedFibers.countDown()
|
||||
}
|
||||
}
|
||||
mutex.locked {
|
||||
|
@ -375,7 +375,7 @@ class FlowFrameworkTests {
|
||||
.withMessage("Nothing useful")
|
||||
.withStackTraceContaining(ReceiveFlow::class.java.name) // Make sure the stack trace is that of the receiving flow
|
||||
bobNode.database.transaction {
|
||||
assertThat(bobNode.checkpointStorage.checkpoints()).isEmpty()
|
||||
assertThat(bobNode.checkpointStorage.checkpoints()).isNotEmpty()
|
||||
}
|
||||
|
||||
assertThat(receivingFiber.isTerminated).isTrue()
|
||||
|
Loading…
Reference in New Issue
Block a user