mirror of
https://github.com/minio/minio.git
synced 2025-01-12 15:33:22 -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"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"math/rand"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"sync"
|
"sync"
|
||||||
@ -87,6 +88,8 @@ func (g *NotificationGroup) Wait() []NotificationPeerErr {
|
|||||||
// The first call to return a non-nil error will be
|
// The first call to return a non-nil error will be
|
||||||
// collected in errs slice and returned by Wait().
|
// collected in errs slice and returned by Wait().
|
||||||
func (g *NotificationGroup) Go(ctx context.Context, f func() error, index int, addr xnet.Host) {
|
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)
|
g.wg.Add(1)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
@ -103,9 +106,9 @@ func (g *NotificationGroup) Go(ctx context.Context, f func() error, index int, a
|
|||||||
ctx := logger.SetReqInfo(ctx, reqInfo)
|
ctx := logger.SetReqInfo(ctx, reqInfo)
|
||||||
logger.LogIf(ctx, err)
|
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 {
|
if i < g.retryCount-1 {
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(100*time.Millisecond + time.Duration(r.Float64()*float64(time.Second)))
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user