@@ -33,6 +33,7 @@ import (
33
33
"github.com/cortexproject/cortex/pkg/cortexpb"
34
34
"github.com/cortexproject/cortex/pkg/querier/series"
35
35
"github.com/cortexproject/cortex/pkg/querier/stats"
36
+ "github.com/cortexproject/cortex/pkg/querysharding"
36
37
"github.com/cortexproject/cortex/pkg/ring"
37
38
"github.com/cortexproject/cortex/pkg/ring/kv"
38
39
"github.com/cortexproject/cortex/pkg/storage/bucket"
@@ -409,9 +410,8 @@ func (q *blocksStoreQuerier) selectSorted(sp *storage.SelectHints, matchers ...*
409
410
}
410
411
411
412
var (
412
- convertedMatchers = convertMatchersToLabelMatcher (matchers )
413
- resSeriesSets = []storage.SeriesSet (nil )
414
- resWarnings = storage .Warnings (nil )
413
+ resSeriesSets = []storage.SeriesSet (nil )
414
+ resWarnings = storage .Warnings (nil )
415
415
416
416
maxChunksLimit = q .limits .MaxChunksPerQueryFromStore (q .userID )
417
417
leftChunksLimit = maxChunksLimit
@@ -420,7 +420,7 @@ func (q *blocksStoreQuerier) selectSorted(sp *storage.SelectHints, matchers ...*
420
420
)
421
421
422
422
queryFunc := func (clients map [BlocksStoreClient ][]ulid.ULID , minT , maxT int64 ) ([]ulid.ULID , error ) {
423
- seriesSets , queriedBlocks , warnings , numChunks , err := q .fetchSeriesFromStores (spanCtx , sp , clients , minT , maxT , matchers , convertedMatchers , maxChunksLimit , leftChunksLimit )
423
+ seriesSets , queriedBlocks , warnings , numChunks , err := q .fetchSeriesFromStores (spanCtx , sp , clients , minT , maxT , matchers , maxChunksLimit , leftChunksLimit )
424
424
if err != nil {
425
425
426
426
return nil , err
@@ -562,7 +562,6 @@ func (q *blocksStoreQuerier) fetchSeriesFromStores(
562
562
minT int64 ,
563
563
maxT int64 ,
564
564
matchers []* labels.Matcher ,
565
- convertedMatchers []storepb.LabelMatcher ,
566
565
maxChunksLimit int ,
567
566
leftChunksLimit int ,
568
567
) ([]storage.SeriesSet , []ulid.ULID , storage.Warnings , int , error ) {
@@ -578,6 +577,12 @@ func (q *blocksStoreQuerier) fetchSeriesFromStores(
578
577
queryLimiter = limiter .QueryLimiterFromContextWithFallback (ctx )
579
578
reqStats = stats .FromContext (ctx )
580
579
)
580
+ matchers , shardingInfo , err := querysharding .ExtractShardingInfo (matchers )
581
+ convertedMatchers := convertMatchersToLabelMatcher (matchers )
582
+
583
+ if err != nil {
584
+ return nil , nil , nil , 0 , err
585
+ }
581
586
582
587
// Concurrently fetch series from all clients.
583
588
for c , blockIDs := range clients {
@@ -595,7 +600,7 @@ func (q *blocksStoreQuerier) fetchSeriesFromStores(
595
600
// retrieved.
596
601
skipChunks := sp != nil && sp .Func == "series"
597
602
598
- req , err := createSeriesRequest (minT , maxT , convertedMatchers , skipChunks , blockIDs )
603
+ req , err := createSeriesRequest (minT , maxT , convertedMatchers , shardingInfo , skipChunks , blockIDs )
599
604
if err != nil {
600
605
return errors .Wrapf (err , "failed to create series request" )
601
606
}
@@ -875,7 +880,7 @@ func (q *blocksStoreQuerier) fetchLabelValuesFromStore(
875
880
return valueSets , warnings , queriedBlocks , nil
876
881
}
877
882
878
- func createSeriesRequest (minT , maxT int64 , matchers []storepb.LabelMatcher , skipChunks bool , blockIDs []ulid.ULID ) (* storepb.SeriesRequest , error ) {
883
+ func createSeriesRequest (minT , maxT int64 , matchers []storepb.LabelMatcher , shardingInfo * storepb. ShardInfo , skipChunks bool , blockIDs []ulid.ULID ) (* storepb.SeriesRequest , error ) {
879
884
// Selectively query only specific blocks.
880
885
hints := & hintspb.SeriesRequestHints {
881
886
BlockMatchers : []storepb.LabelMatcher {
@@ -899,6 +904,7 @@ func createSeriesRequest(minT, maxT int64, matchers []storepb.LabelMatcher, skip
899
904
PartialResponseStrategy : storepb .PartialResponseStrategy_ABORT ,
900
905
Hints : anyHints ,
901
906
SkipChunks : skipChunks ,
907
+ ShardInfo : shardingInfo ,
902
908
}, nil
903
909
}
904
910
0 commit comments