mirror of
https://github.com/corda/corda.git
synced 2025-02-20 17:33:15 +00:00
Add jitter to retries (#3749)
* Add jitter to retries * Address comments
This commit is contained in:
parent
6255459ce7
commit
dd4923e80e
@ -590,10 +590,11 @@ class SingleThreadedStateMachineManager(
|
||||
private fun scheduleTimeoutException(flow: Flow, retryCount: Int): ScheduledFuture<*> {
|
||||
return with(serviceHub.configuration.flowTimeout) {
|
||||
val timeoutDelaySeconds = timeout.seconds * Math.pow(backoffBase, retryCount.toDouble()).toLong()
|
||||
val jitteredDelaySeconds = maxOf(1L, timeoutDelaySeconds/2 + (Math.random() * timeoutDelaySeconds/2).toLong())
|
||||
timeoutScheduler.schedule({
|
||||
val event = Event.Error(FlowTimeoutException(maxRestartCount))
|
||||
flow.fiber.scheduleEvent(event)
|
||||
}, timeoutDelaySeconds, TimeUnit.SECONDS)
|
||||
}, jitteredDelaySeconds, TimeUnit.SECONDS)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,6 @@ rpcSettings = {
|
||||
}
|
||||
flowTimeout {
|
||||
timeout = 30 seconds
|
||||
maxRestartCount = 5
|
||||
maxRestartCount = 6
|
||||
backoffBase = 1.8
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user