Skip to content

Commit

Permalink
pkg: fix retry getBackoffInMs panic when sleep overflowed (#2280) (#2287
Browse files Browse the repository at this point in the history
)
  • Loading branch information
ti-chi-bot authored Jul 18, 2021
1 parent 0a6e133 commit 9f2c5ca
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/retry/retry_with_opt.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ func getBackoffInMs(backoffBaseInMs, backoffCapInMs, try float64) time.Duration
if temp <= 0 {
temp = 1
}
sleep := temp + rand.Int63n(temp)
backOff := math.Min(backoffCapInMs, float64(rand.Int63n(sleep*3))+backoffBaseInMs)
sleep := (temp + rand.Int63n(temp)) * 3
if sleep <= 0 {
sleep = math.MaxInt64
}
backOff := math.Min(backoffCapInMs, float64(rand.Int63n(sleep))+backoffBaseInMs)
return time.Duration(backOff) * time.Millisecond
}

0 comments on commit 9f2c5ca

Please sign in to comment.