mirror of
https://github.com/minio/minio.git
synced 2025-01-11 15:03:22 -05:00
init: Use constant time retries (#8769)
Exponential backoff does not seem like a good fit for this function since we can expect a few roundtrips on initial startup. This retry loop get slow pretty quickly with initial wait being 1 second and each try being double the wait until 30 seconds is reached. Instead simply try 2 times per second.
This commit is contained in:
parent
aa2e89bfe3
commit
3d318bae76
@ -307,13 +307,6 @@ func waitForFormatXL(firstDisk bool, endpoints Endpoints, setCount, drivesPerSet
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Done channel is used to close any lingering retry routine, as soon
|
|
||||||
// as this function returns.
|
|
||||||
doneCh := make(chan struct{})
|
|
||||||
|
|
||||||
// Indicate to our retry routine to exit cleanly, upon this function return.
|
|
||||||
defer close(doneCh)
|
|
||||||
|
|
||||||
// prepare getElapsedTime() to calculate elapsed time since we started trying formatting disks.
|
// prepare getElapsedTime() to calculate elapsed time since we started trying formatting disks.
|
||||||
// All times are rounded to avoid showing milli, micro and nano seconds
|
// All times are rounded to avoid showing milli, micro and nano seconds
|
||||||
formatStartTime := time.Now().Round(time.Second)
|
formatStartTime := time.Now().Round(time.Second)
|
||||||
@ -321,13 +314,16 @@ func waitForFormatXL(firstDisk bool, endpoints Endpoints, setCount, drivesPerSet
|
|||||||
return time.Now().Round(time.Second).Sub(formatStartTime).String()
|
return time.Now().Round(time.Second).Sub(formatStartTime).String()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait on the jitter retry loop.
|
// Wait on each try for an update.
|
||||||
retryTimerCh := newRetryTimerSimple(doneCh)
|
ticker := time.NewTicker(500 * time.Millisecond)
|
||||||
|
defer ticker.Stop()
|
||||||
|
var tries int
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case retryCount := <-retryTimerCh:
|
case <-ticker.C:
|
||||||
format, err := connectLoadInitFormats(retryCount, firstDisk, endpoints, setCount, drivesPerSet, deploymentID)
|
format, err := connectLoadInitFormats(tries, firstDisk, endpoints, setCount, drivesPerSet, deploymentID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
tries++
|
||||||
switch err {
|
switch err {
|
||||||
case errNotFirstDisk:
|
case errNotFirstDisk:
|
||||||
// Fresh setup, wait for first server to be up.
|
// Fresh setup, wait for first server to be up.
|
||||||
|
Loading…
Reference in New Issue
Block a user