Skip to content

Commit 51a4ea4

Browse files
authored
Merge pull request #1549 from go-redis/feature/retry-overflow
Guard against overflow in retry
2 parents caee288 + f92951b commit 51a4ea4

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

internal/internal.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ func RetryBackoff(retry int, minBackoff, maxBackoff time.Duration) time.Duration
1515
}
1616

1717
d := minBackoff << uint(retry)
18+
if d < minBackoff {
19+
return maxBackoff
20+
}
21+
1822
d = minBackoff + time.Duration(rand.Int63n(int64(d)))
1923

2024
if d > maxBackoff || d < minBackoff {

0 commit comments

Comments
 (0)