Merge pull request #6969 from corda/nandor-os-4.5-os-4.6-20211011

NAAS-300 Forward merge notary ETA fix
This commit is contained in:
Christian Sailer 2021-10-11 15:57:02 +01:00 committed by GitHub
commit 22f81b161d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 4 deletions

View File

@ -17,9 +17,14 @@ interface IdempotentFlow
* next available notary cluster member.
*
* Note that any sub-flows called by a [TimedFlow] are assumed to be [IdempotentFlow] and will NOT have checkpoints
* persisted. Otherwise, it wouldn't be possible to correctly reset the [TimedFlow].
* persisted. Otherwise, it wouldn't be possible to correctly reset the [TimedFlow]. An implication of this is that
* idempotent flows must not only return the same final result of the flow, but if a flow returns multiple messages
* the full set of messages must be returned on subsequent attempts in the same order as the first flow.
*
* An example of this would be if a notary returns an ETA message at any point, then any subsequent retries of the
* flow must also send such a message before returning the actual notarisation result.
*/
// TODO: allow specifying retry settings per flow
interface TimedFlow : IdempotentFlow {
val isTimeoutEnabled: Boolean
}
}

View File

@ -58,8 +58,17 @@ abstract class NotaryServiceFlow(val otherSideSession: FlowSession, val service:
verifyTransaction(requestPayload)
val eta = service.getEstimatedWaitTime(tx.inputs.size + tx.references.size)
if (eta > etaThreshold && counterpartyCanHandleBackPressure()) {
otherSideSession.send(WaitTimeUpdate(eta))
if (counterpartyCanHandleBackPressure()) {
if (eta > etaThreshold) {
otherSideSession.send(WaitTimeUpdate(eta))
} else if (stateMachine.ourSenderUUID == null) {
// This implies we are handling a flow retry. As we may have already responded
// with an ETA message on a previous attempt, we must ensure a new unique
// message id is used to prevent the actual response from being de-duplicated
// by the client. This sleep forces an increment of the suspend component of
// the message id. See Jira NAAS-295 for full details.
sleep(Duration.ZERO)
}
}
service.commitInputStates(