From f86d3538f6063c34c7562cad58f3f3780b3d26ec Mon Sep 17 00:00:00 2001 From: Klaus Post Date: Thu, 12 Nov 2020 09:17:56 -0800 Subject: [PATCH] Allow deeper sleep (#10883) Allow each crawler operation to sleep up to 10 seconds on very heavily loaded systems. This will of course make minimum crawler speed less, but should be more effective at stopping. --- cmd/data-crawler.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/cmd/data-crawler.go b/cmd/data-crawler.go index 381d81858..7c80ff50a 100644 --- a/cmd/data-crawler.go +++ b/cmd/data-crawler.go @@ -775,13 +775,16 @@ func (i *crawlItem) objectPath() string { return path.Join(i.prefix, i.objectName) } -// sleepDuration multiplies the duration d by x and sleeps if is more than 100 micro seconds. -// sleep is limited to max 1 second. +// sleepDuration multiplies the duration d by x +// and sleeps if is more than 100 micro seconds. +// Sleep is limited to max 15 seconds. func sleepDuration(d time.Duration, x float64) { + const maxWait = 15 * time.Second + const minWait = 100 * time.Microsecond // Don't sleep for really small amount of time - if d := time.Duration(float64(d) * x); d > time.Microsecond*100 { - if d > time.Second { - d = time.Second + if d := time.Duration(float64(d) * x); d > minWait { + if d > maxWait { + d = maxWait } time.Sleep(d) }