21227: Don't reduce outgoing request concurrency below 4.
authorTom Clegg <tom@curii.com>
Mon, 4 Dec 2023 23:11:47 +0000 (18:11 -0500)
committerTom Clegg <tom@curii.com>
Mon, 4 Dec 2023 23:11:47 +0000 (18:11 -0500)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@curii.com>

sdk/go/arvados/limiter.go

index dc944160ab2dd5d459a31fa2386ebe9a5f6bb2c3..9edc5386a7655c3f1d9e31bcb0d3f55b2a999c87 100644 (file)
@@ -16,6 +16,7 @@ import (
 var (
        requestLimiterQuietPeriod        = time.Second
        requestLimiterInitialLimit int64 = 8
+       requestLimiterMinimumLimit int64 = 4
 )
 
 type requestLimiter struct {
@@ -145,6 +146,12 @@ func (rl *requestLimiter) Report(resp *http.Response, err error) bool {
                if max := rl.current * 2; max < rl.limit {
                        rl.limit = max
                }
+               if min := requestLimiterMinimumLimit; min > rl.limit {
+                       // If limit is too low, programs like
+                       // controller and test suites can end up with
+                       // too few slots to complete a single request.
+                       rl.limit = min
+               }
                if rl.maxlimit > 0 && rl.maxlimit < rl.limit {
                        rl.limit = rl.maxlimit
                }