Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce distributor memory usage when error volume is high #6095

Merged
merged 2 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
* [ENHANCEMENT] Ingester: Add link to renew 10% of the ingesters tokens in the admin page. #6063
* [ENHANCEMENT] Ruler: Add support for filtering by `state` and `health` field on Rules API. #6040
* [ENHANCEMENT] Ruler: Add support for filtering by `match` field on Rules API. #6083
* [ENHANCEMENT] Distributor: Reduce memory usage when error volume is high. #6095
* [ENHANCEMENT] Compactor: Add unique execution ID for each compaction cycle in log for easy debugging. #6097
* [BUGFIX] Configsdb: Fix endline issue in db password. #5920
* [BUGFIX] Ingester: Fix `user` and `type` labels for the `cortex_ingester_tsdb_head_samples_appended_total` TSDB metric. #5952
Expand Down
15 changes: 10 additions & 5 deletions pkg/ring/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,7 @@ func (b *batchTracker) record(instance instance, err error) {
if err != nil {
// Track the number of errors by error family, and if it exceeds maxFailures
// shortcut the waiting rpc.
wrappedErr := httpgrpcutil.WrapHTTPGrpcError(err, "addr=%s state=%s zone=%s", instance.desc.Addr, instance.desc.State, instance.desc.Zone)
errCount := instance.itemTrackers[i].recordError(wrappedErr)
errCount := instance.itemTrackers[i].recordError(err)
// We should return an error if we reach the maxFailure (quorum) on a given error family OR
// we dont have any remaining ingesters to try
// Ex: 2xx, 4xx, 5xx -> return 4xx
Expand All @@ -162,13 +161,17 @@ func (b *batchTracker) record(instance instance, err error) {
// Ex: 5xx, _, 5xx -> return 5xx
if errCount > int32(sampleTrackers[i].maxFailures) {
if b.rpcsFailed.Inc() == 1 {
b.err <- httpgrpcutil.WrapHTTPGrpcError(sampleTrackers[i].getError(), "maxFailure (quorum) on a given error family")
b.err <- httpgrpcutil.WrapHTTPGrpcError(
sampleTrackers[i].getError(), "maxFailure (quorum) on a given error family, addr=%s state=%s zone=%s",
instance.desc.Addr, instance.desc.State, instance.desc.Zone)
}
continue
}
if sampleTrackers[i].remaining.Dec() == 0 {
if b.rpcsFailed.Inc() == 1 {
b.err <- httpgrpcutil.WrapHTTPGrpcError(sampleTrackers[i].getError(), "not enough remaining instances to try")
b.err <- httpgrpcutil.WrapHTTPGrpcError(
sampleTrackers[i].getError(), "not enough remaining instances to try, addr=%s state=%s zone=%s",
instance.desc.Addr, instance.desc.State, instance.desc.Zone)
}
continue
}
Expand All @@ -187,7 +190,9 @@ func (b *batchTracker) record(instance instance, err error) {
// Ex: 4xx, 5xx, 2xx
if sampleTrackers[i].remaining.Dec() == 0 {
if b.rpcsFailed.Inc() == 1 {
b.err <- httpgrpcutil.WrapHTTPGrpcError(sampleTrackers[i].getError(), "not enough remaining instances to try")
b.err <- httpgrpcutil.WrapHTTPGrpcError(
sampleTrackers[i].getError(), "not enough remaining instances to try, addr=%s state=%s zone=%s",
instance.desc.Addr, instance.desc.State, instance.desc.Zone)
}
}
}
Expand Down
Loading