@@ -583,21 +583,9 @@ func (d *Distributor) Push(ctx context.Context, req *cortexpb.WriteRequest) (*co
583
583
inflight := d .inflightPushRequests .Inc ()
584
584
defer d .inflightPushRequests .Dec ()
585
585
586
- if d .cfg .InstanceLimits .MaxInflightPushRequests > 0 && inflight > int64 (d .cfg .InstanceLimits .MaxInflightPushRequests ) {
587
- return nil , errTooManyInflightPushRequests
588
- }
589
-
590
- if d .cfg .InstanceLimits .MaxIngestionRate > 0 {
591
- if rate := d .ingestionRate .Rate (); rate >= d .cfg .InstanceLimits .MaxIngestionRate {
592
- return nil , errMaxSamplesPushRateLimitReached
593
- }
594
- }
595
-
596
586
now := time .Now ()
597
587
d .activeUsers .UpdateUserTimestamp (userID , now )
598
588
599
- removeReplica := false
600
-
601
589
numSamples := 0
602
590
numExemplars := 0
603
591
for _ , ts := range req .Timeseries {
@@ -610,6 +598,17 @@ func (d *Distributor) Push(ctx context.Context, req *cortexpb.WriteRequest) (*co
610
598
// Count the total number of metadata in.
611
599
d .incomingMetadata .WithLabelValues (userID ).Add (float64 (len (req .Metadata )))
612
600
601
+ if d .cfg .InstanceLimits .MaxInflightPushRequests > 0 && inflight > int64 (d .cfg .InstanceLimits .MaxInflightPushRequests ) {
602
+ return nil , errTooManyInflightPushRequests
603
+ }
604
+
605
+ if d .cfg .InstanceLimits .MaxIngestionRate > 0 {
606
+ if rate := d .ingestionRate .Rate (); rate >= d .cfg .InstanceLimits .MaxIngestionRate {
607
+ return nil , errMaxSamplesPushRateLimitReached
608
+ }
609
+ }
610
+
611
+ removeReplica := false
613
612
// Cache user limit with overrides so we spend less CPU doing locking. See issue #4904
614
613
limits := d .limits .GetOverridesForUser (userID )
615
614
0 commit comments