mirror of
https://github.com/minio/minio.git
synced 2025-01-12 07:23:23 -05:00
add variadic delays in peer notification retries (#17592)
just adds more `jitter` in our retries to avoid burst flooding for peer calls.
This commit is contained in:
parent
6335a48a53
commit
f41edb23e2
@ -22,6 +22,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"sync"
|
||||
@ -87,6 +88,8 @@ func (g *NotificationGroup) Wait() []NotificationPeerErr {
|
||||
// The first call to return a non-nil error will be
|
||||
// collected in errs slice and returned by Wait().
|
||||
func (g *NotificationGroup) Go(ctx context.Context, f func() error, index int, addr xnet.Host) {
|
||||
r := rand.New(rand.NewSource(time.Now().UnixNano()))
|
||||
|
||||
g.wg.Add(1)
|
||||
|
||||
go func() {
|
||||
@ -103,9 +106,9 @@ func (g *NotificationGroup) Go(ctx context.Context, f func() error, index int, a
|
||||
ctx := logger.SetReqInfo(ctx, reqInfo)
|
||||
logger.LogIf(ctx, err)
|
||||
}
|
||||
// Wait for one second and no need wait after last attempt.
|
||||
// Wait for a minimum of 100ms and dynamically increase this based on number of attempts.
|
||||
if i < g.retryCount-1 {
|
||||
time.Sleep(1 * time.Second)
|
||||
time.Sleep(100*time.Millisecond + time.Duration(r.Float64()*float64(time.Second)))
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user