Skip to content

Commit 8a416fc

Browse files
authored
Fix a bug in MetricsForLabelMatchersStream (#4745)
Signed-off-by: 🌲 Harry 🌊 John 🏔 <[email protected]>
1 parent 618a41b commit 8a416fc

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
* [BUGFIX] Distributor: Fix a memory leak in distributor due to the cluster label. #4739
4141
* [ENHANCEMENT] Compactor: uploading blocks no compaction marks to the global location and introduce a new metric #4729
4242
* `cortex_bucket_blocks_marked_for_no_compaction_count`: Total number of blocks marked for no compaction in the bucket.
43+
* [ENHANCEMENT] Querier: Reduce the number of series that are kept in memory while streaming from ingesters. #4745
4344

4445
## 1.11.0 2021-11-25
4546

pkg/cortexpb/compat.go

+6
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,12 @@ func FromLabelAdaptersToMetric(ls []LabelAdapter) model.Metric {
102102
return util.LabelsToMetric(FromLabelAdaptersToLabels(ls))
103103
}
104104

105+
// FromLabelAdaptersToMetric converts []LabelAdapter to a model.Metric with copy.
106+
// Don't do this on any performance sensitive paths.
107+
func FromLabelAdaptersToMetricWithCopy(ls []LabelAdapter) model.Metric {
108+
return util.LabelsToMetric(FromLabelAdaptersToLabelsWithCopy(ls))
109+
}
110+
105111
// FromMetricsToLabelAdapters converts model.Metric to []LabelAdapter.
106112
// Don't do this on any performance sensitive paths.
107113
// The result is sorted.

pkg/distributor/distributor.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,7 @@ func (d *Distributor) MetricsForLabelMatchersStream(ctx context.Context, from, t
10581058
}
10591059

10601060
for _, metric := range resp.Metric {
1061-
m := cortexpb.FromLabelAdaptersToMetric(metric.Labels)
1061+
m := cortexpb.FromLabelAdaptersToMetricWithCopy(metric.Labels)
10621062

10631063
if err := queryLimiter.AddSeries(cortexpb.FromMetricsToLabelAdapters(m)); err != nil {
10641064
return nil, err

0 commit comments

Comments
 (0)