mirror of
https://github.com/minio/minio.git
synced 2025-04-20 02:27:50 -04:00
fix: startup being slow - wait only if IOCount > 0
This commit is contained in:
parent
c22a387695
commit
44e23b7f4f
@ -676,7 +676,9 @@ func (h *healSequence) queueHealTask(source healSource, healType madmin.HealItem
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Wait and proceed if there are active requests
|
// Wait and proceed if there are active requests
|
||||||
|
if opts.IOCount > 0 {
|
||||||
waitForLowHTTPReq(opts.IOCount, opts.Sleep)
|
waitForLowHTTPReq(opts.IOCount, opts.Sleep)
|
||||||
|
}
|
||||||
|
|
||||||
h.mutex.Lock()
|
h.mutex.Lock()
|
||||||
h.scannedItemsMap[healType]++
|
h.scannedItemsMap[healType]++
|
||||||
|
@ -54,20 +54,25 @@ func (h *healRoutine) queueHealTask(task healTask) {
|
|||||||
h.tasks <- task
|
h.tasks <- task
|
||||||
}
|
}
|
||||||
|
|
||||||
func waitForLowHTTPReq(tolerance int, maxWait time.Duration) {
|
func waitForLowHTTPReq(maxIO int, maxWait time.Duration) {
|
||||||
|
// No need to wait run at full speed.
|
||||||
|
if maxIO <= 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// At max 10 attempts to wait with 100 millisecond interval before proceeding
|
// At max 10 attempts to wait with 100 millisecond interval before proceeding
|
||||||
waitCount := 10
|
waitCount := 10
|
||||||
waitTick := 100 * time.Millisecond
|
waitTick := 100 * time.Millisecond
|
||||||
|
|
||||||
// Bucket notification and http trace are not costly, it is okay to ignore them
|
// Bucket notification and http trace are not costly, it is okay to ignore them
|
||||||
// while counting the number of concurrent connections
|
// while counting the number of concurrent connections
|
||||||
toleranceFn := func() int {
|
maxIOFn := func() int {
|
||||||
return tolerance + globalHTTPListen.NumSubscribers() + globalHTTPTrace.NumSubscribers()
|
return maxIO + globalHTTPListen.NumSubscribers() + globalHTTPTrace.NumSubscribers()
|
||||||
}
|
}
|
||||||
|
|
||||||
if httpServer := newHTTPServerFn(); httpServer != nil {
|
if httpServer := newHTTPServerFn(); httpServer != nil {
|
||||||
// Any requests in progress, delay the heal.
|
// Any requests in progress, delay the heal.
|
||||||
for httpServer.GetRequestCount() >= toleranceFn() {
|
for httpServer.GetRequestCount() >= maxIOFn() {
|
||||||
time.Sleep(waitTick)
|
time.Sleep(waitTick)
|
||||||
waitCount--
|
waitCount--
|
||||||
if waitCount == 0 {
|
if waitCount == 0 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user