Skip to content

Commit 0fd5bdd

Browse files
authored
Update comment on rate-limit error (#4379)
It is no longer true that clients always discard. Also move the comment next to the error. Signed-off-by: Bryan Boreham <[email protected]>
1 parent dc43fee commit 0fd5bdd

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

pkg/distributor/distributor.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -722,11 +722,12 @@ func (d *Distributor) Push(ctx context.Context, req *cortexpb.WriteRequest) (*co
722722
// Ensure the request slice is reused if the request is rate limited.
723723
cortexpb.ReuseSlice(req.Timeseries)
724724

725-
// Return a 4xx here to have the client discard the data and not retry. If a client
726-
// is sending too much data consistently we will unlikely ever catch up otherwise.
727725
validation.DiscardedSamples.WithLabelValues(validation.RateLimited, userID).Add(float64(validatedSamples))
728726
validation.DiscardedExemplars.WithLabelValues(validation.RateLimited, userID).Add(float64(validatedExemplars))
729727
validation.DiscardedMetadata.WithLabelValues(validation.RateLimited, userID).Add(float64(len(validatedMetadata)))
728+
// Return a 429 here to tell the client it is going too fast.
729+
// Client may discard the data or slow down and re-send.
730+
// Prometheus v2.26 added a remote-write option 'retry_on_http_429'.
730731
return nil, httpgrpc.Errorf(http.StatusTooManyRequests, "ingestion rate limit (%v) exceeded while adding %d samples and %d metadata", d.ingestionRateLimiter.Limit(now, userID), validatedSamples, len(validatedMetadata))
731732
}
732733

0 commit comments

Comments
 (0)