mirror of
https://github.com/corda/corda.git
synced 2025-01-27 06:39: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
|
@Suspendable
|
||||||
override fun initiateFlow(otherParty: Party, sessionFlow: FlowLogic<*>): FlowSession {
|
override fun initiateFlow(otherParty: Party, sessionFlow: FlowLogic<*>): FlowSession {
|
||||||
val sessionKey = Pair(sessionFlow, otherParty)
|
val sessionKey = Pair(sessionFlow, otherParty)
|
||||||
|
@ -452,10 +452,14 @@ class StateMachineManagerImpl(
|
|||||||
}
|
}
|
||||||
endAllFiberSessions(fiber, result, propagated)
|
endAllFiberSessions(fiber, result, propagated)
|
||||||
} finally {
|
} finally {
|
||||||
|
if (result.isSuccess) {
|
||||||
fiber.commitTransaction()
|
fiber.commitTransaction()
|
||||||
decrementLiveFibers()
|
|
||||||
totalFinishedFlows.inc()
|
totalFinishedFlows.inc()
|
||||||
unfinishedFibers.countDown()
|
unfinishedFibers.countDown()
|
||||||
|
} else {
|
||||||
|
fiber.rollbackTransaction()
|
||||||
|
}
|
||||||
|
decrementLiveFibers()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mutex.locked {
|
mutex.locked {
|
||||||
|
@ -375,7 +375,7 @@ class FlowFrameworkTests {
|
|||||||
.withMessage("Nothing useful")
|
.withMessage("Nothing useful")
|
||||||
.withStackTraceContaining(ReceiveFlow::class.java.name) // Make sure the stack trace is that of the receiving flow
|
.withStackTraceContaining(ReceiveFlow::class.java.name) // Make sure the stack trace is that of the receiving flow
|
||||||
bobNode.database.transaction {
|
bobNode.database.transaction {
|
||||||
assertThat(bobNode.checkpointStorage.checkpoints()).isEmpty()
|
assertThat(bobNode.checkpointStorage.checkpoints()).isNotEmpty()
|
||||||
}
|
}
|
||||||
|
|
||||||
assertThat(receivingFiber.isTerminated).isTrue()
|
assertThat(receivingFiber.isTerminated).isTrue()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user