Skip to content

Commit 39161ca

Browse files
committed
Return 503 on hitting distributor client inflight request limit
Signed-off-by: Anna Tran <[email protected]>
1 parent ecc7172 commit 39161ca

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

pkg/distributor/distributor.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ var (
5555
// Distributor instance limits errors.
5656
errTooManyInflightPushRequests = errors.New("too many inflight push requests in distributor")
5757
errMaxSamplesPushRateLimitReached = errors.New("distributor's samples push rate limit reached")
58-
errTooManyInflightClientRequests = errors.New("too many inflight ingester client requests in distributor")
5958
)
6059

6160
const (
@@ -680,7 +679,7 @@ func (d *Distributor) Push(ctx context.Context, req *cortexpb.WriteRequest) (*co
680679
// only reject requests at this stage to allow distributor to finish sending the current batch request to all ingesters
681680
// even if we've exceeded the MaxInflightClientRequests in the `doBatch`
682681
if d.cfg.InstanceLimits.MaxInflightClientRequests > 0 && d.inflightClientRequests.Load() > int64(d.cfg.InstanceLimits.MaxInflightClientRequests) {
683-
return nil, errTooManyInflightClientRequests
682+
return nil, httpgrpc.Errorf(http.StatusServiceUnavailable, "too many inflight ingester client requests in distributor")
684683
}
685684

686685
removeReplica := false

pkg/distributor/distributor_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,8 @@ func TestDistributor_PushInstanceLimits(t *testing.T) {
863863
preInflightClient: 103,
864864
inflightClientLimit: 101,
865865
pushes: []testPush{
866-
{samples: 100, expectedError: errTooManyInflightClientRequests},
866+
{samples: 100, expectedError: httpgrpc.Errorf(http.StatusServiceUnavailable,
867+
"too many inflight ingester client requests in distributor")},
867868
},
868869
},
869870
"below ingestion rate limit": {

0 commit comments

Comments
 (0)