From 1cd8e1d8b633550e18a108a0f042941afab6e923 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Mon, 2 Jan 2023 01:40:09 -0800 Subject: [PATCH] remove the startup jitter before locks() (#16340) --- cmd/server-main.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/cmd/server-main.go b/cmd/server-main.go index 5d8cf3e90..6c0b138f2 100644 --- a/cmd/server-main.go +++ b/cmd/server-main.go @@ -377,10 +377,6 @@ func initServer(ctx context.Context, newObject ObjectLayer) error { minimum: 3 * time.Second, }) - // Do an initial random sleep to avoid stampeding herd of initial - // lock request. This will spread locks requests over 1 second. - time.Sleep(time.Duration(r.Float64() * float64(time.Second))) - for { select { case <-ctx.Done(): @@ -403,10 +399,11 @@ func initServer(ctx context.Context, newObject ObjectLayer) error { lkctx, err := txnLk.GetLock(ctx, lockTimeout) if err != nil { logger.Info("Waiting for all MinIO sub-systems to be initialized.. trying to acquire lock") - bootstrapTrace(fmt.Sprintf("lock not available. error: %v. sleeping before retry", err)) + waitDuration := time.Duration(r.Float64() * 2 * float64(time.Second)) + bootstrapTrace(fmt.Sprintf("lock not available. error: %v. sleeping for %v before retry", err, waitDuration)) // Sleep 0 -> 2 seconds to average 1 second retry interval. - time.Sleep(time.Duration(r.Float64() * 2 * float64(time.Second))) + time.Sleep(waitDuration) continue }