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

add context cancellation checks on GetSeries #5827

Merged
merged 3 commits into from
Mar 28, 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 @@ -29,6 +29,7 @@
* [ENHANCEMENT] Ingester: Add new ingester metric `cortex_ingester_max_inflight_query_requests`. #5798
* [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
* [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
* [ENHANCEMENT] Querier: Add context error check when converting Metrics to SeriesSet for GetSeries on distributorQuerier. #5827
* [BUGFIX] Distributor: Do not use label with empty values for sharding #5717
* [BUGFIX] Query Frontend: queries with negative offset should check whether it is cacheable or not. #5719
* [BUGFIX] Redis Cache: pass `cache_size` config correctly. #5734
Expand Down
2 changes: 1 addition & 1 deletion pkg/querier/distributor_queryable.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func (q *distributorQuerier) Select(ctx context.Context, sortSeries bool, sp *st
if err != nil {
return storage.ErrSeriesSet(err)
}
return series.MetricsToSeriesSet(sortSeries, ms)
return series.MetricsToSeriesSet(ctx, sortSeries, ms)
}

return q.streamingSelect(ctx, sortSeries, minT, maxT, matchers)
Expand Down
6 changes: 5 additions & 1 deletion pkg/querier/series/series_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package series

import (
"context"
"sort"

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

// MetricsToSeriesSet creates a storage.SeriesSet from a []metric.Metric
func MetricsToSeriesSet(sortSeries bool, ms []metric.Metric) storage.SeriesSet {
func MetricsToSeriesSet(ctx context.Context, sortSeries bool, ms []metric.Metric) storage.SeriesSet {
series := make([]storage.Series, 0, len(ms))
for _, m := range ms {
if ctx.Err() != nil {
return storage.ErrSeriesSet(ctx.Err())
}
series = append(series, &ConcreteSeries{
labels: metricToLabels(m.Metric),
samples: nil,
Expand Down
Loading