From ffe5c564b76b9a6b3772ea60f1f100a66728c89d Mon Sep 17 00:00:00 2001 From: "M. J. Fromberger" Date: Thu, 17 Feb 2022 12:18:19 -0800 Subject: [PATCH] consensus: start the timeout ticker before replay (backport #7844) --- consensus/state.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/consensus/state.go b/consensus/state.go index 9ca9f1d57..7289a8375 100644 --- a/consensus/state.go +++ b/consensus/state.go @@ -305,6 +305,15 @@ func (cs *State) OnStart() error { } } + // we need the timeoutRoutine for replay so + // we don't block on the tick chan. + // NOTE: we will get a build up of garbage go routines + // firing on the tockChan until the receiveRoutine is started + // to deal with them (by that point, at most one will be valid) + if err := cs.timeoutTicker.Start(); err != nil { + return err + } + // We may have lost some votes if the process crashed reload from consensus // log to catchup. if cs.doWALCatchup { @@ -361,15 +370,6 @@ func (cs *State) OnStart() error { return err } - // we need the timeoutRoutine for replay so - // we don't block on the tick chan. - // NOTE: we will get a build up of garbage go routines - // firing on the tockChan until the receiveRoutine is started - // to deal with them (by that point, at most one will be valid) - if err := cs.timeoutTicker.Start(); err != nil { - return err - } - // Double Signing Risk Reduction if err := cs.checkDoubleSigningRisk(cs.Height); err != nil { return err