Skip to content

Commit a5fa68d

Browse files
authored
add context cancellation checks on GetSeries (#5827)
* add context cancellation checks on GetSeries Signed-off-by: Erlan Zholdubai uulu <[email protected]> * add context cancellation checks on GetSeries Signed-off-by: Erlan Zholdubai uulu <[email protected]> * add context cancellation checks on GetSeries, add changelog Signed-off-by: Erlan Zholdubai uulu <[email protected]> --------- Signed-off-by: Erlan Zholdubai uulu <[email protected]>
1 parent 211783b commit a5fa68d

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
* [ENHANCEMENT] Ingester: Add new ingester metric `cortex_ingester_max_inflight_query_requests`. #5798
3030
* [ENHANCEMENT] Query: Added `query_storage_wall_time` to Query Frontend and Ruler query stats log for wall time spent on fetching data from storage. Query evaluation is not included. #5799
3131
* [ENHANCEMENT] Query: Added additional max query length check at Query Frontend and Ruler. Added `-querier.ignore-max-query-length` flag to disable max query length check at Querier. #5808
32+
* [ENHANCEMENT] Querier: Add context error check when converting Metrics to SeriesSet for GetSeries on distributorQuerier. #5827
3233
* [BUGFIX] Distributor: Do not use label with empty values for sharding #5717
3334
* [BUGFIX] Query Frontend: queries with negative offset should check whether it is cacheable or not. #5719
3435
* [BUGFIX] Redis Cache: pass `cache_size` config correctly. #5734

pkg/querier/distributor_queryable.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ func (q *distributorQuerier) Select(ctx context.Context, sortSeries bool, sp *st
136136
if err != nil {
137137
return storage.ErrSeriesSet(err)
138138
}
139-
return series.MetricsToSeriesSet(sortSeries, ms)
139+
return series.MetricsToSeriesSet(ctx, sortSeries, ms)
140140
}
141141

142142
return q.streamingSelect(ctx, sortSeries, minT, maxT, matchers)

pkg/querier/series/series_set.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package series
1818

1919
import (
20+
"context"
2021
"sort"
2122

2223
"github.com/prometheus/common/model"
@@ -167,9 +168,12 @@ func MatrixToSeriesSet(sortSeries bool, m model.Matrix) storage.SeriesSet {
167168
}
168169

169170
// MetricsToSeriesSet creates a storage.SeriesSet from a []metric.Metric
170-
func MetricsToSeriesSet(sortSeries bool, ms []metric.Metric) storage.SeriesSet {
171+
func MetricsToSeriesSet(ctx context.Context, sortSeries bool, ms []metric.Metric) storage.SeriesSet {
171172
series := make([]storage.Series, 0, len(ms))
172173
for _, m := range ms {
174+
if ctx.Err() != nil {
175+
return storage.ErrSeriesSet(ctx.Err())
176+
}
173177
series = append(series, &ConcreteSeries{
174178
labels: metricToLabels(m.Metric),
175179
samples: nil,

0 commit comments

Comments
 (0)