fix: use NewSafeTimer

Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
This commit is contained in:
Yoan Blanc 2022-04-11 19:37:14 +02:00
parent 5e8254beda
commit 3e79d58e4a
No known key found for this signature in database
GPG Key ID: 6058CF4574298812
1 changed files with 4 additions and 1 deletions

View File

@ -109,8 +109,11 @@ TRY:
}
// Wait to avoid thundering herd
timer, cancel := helper.NewSafeTimer(helper.RandomStagger(c.config.RPCHoldTimeout / structs.JitterFraction))
defer cancel()
select {
case <-time.After(helper.RandomStagger(c.config.RPCHoldTimeout / structs.JitterFraction)):
case <-timer.C:
// If we are going to retry a blocking query we need to update the time to block so it finishes by our deadline.
if info, ok := args.(structs.RPCInfo); ok && info.TimeToBlock() > 0 {
newBlockTime := time.Until(deadline)