Skip to content

Commit 19eb141

Browse files
committed
fix data race
Signed-off-by: yeya24 <[email protected]>
1 parent 6d6b81a commit 19eb141

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

pkg/query/querier.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ func (q *querier) selectFn(ctx context.Context, hints *storage.SelectHints, ms .
332332
}
333333

334334
aggrs := aggrsFromFunc(hints.Func)
335-
maxResolutionMillis := maxResolutionFromSelectHints(q.maxResolutionMillis, *hints)
335+
maxResolutionMillis := maxResolutionFromSelectHints(q.maxResolutionMillis, hints.Range, hints.Func)
336336

337337
// TODO(bwplotka): Pass it using the SeriesRequest instead of relying on context.
338338
ctx = context.WithValue(ctx, store.StoreMatcherKey, q.storeDebugMatchers)
@@ -475,10 +475,10 @@ func (q *querier) LabelNames(ctx context.Context, hints *storage.LabelHints, mat
475475
func (q *querier) Close() error { return nil }
476476

477477
// maxResolutionFromSelectHints finds the max possible resolution by inferring from the promql query.
478-
func maxResolutionFromSelectHints(maxResolutionMillis int64, hints storage.SelectHints) int64 {
479-
if hints.Range > 0 {
480-
if _, ok := promqlFuncRequiresTwoSamples[hints.Func]; ok {
481-
maxResolutionMillis = min(maxResolutionMillis, hints.Range/2)
478+
func maxResolutionFromSelectHints(maxResolutionMillis int64, hintsRange int64, hintsFunc string) int64 {
479+
if hintsRange > 0 {
480+
if _, ok := promqlFuncRequiresTwoSamples[hintsFunc]; ok {
481+
maxResolutionMillis = min(maxResolutionMillis, hintsRange/2)
482482
}
483483
}
484484
return maxResolutionMillis

pkg/query/querier_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1406,7 +1406,7 @@ func TestMaxResolutionFromSelectHints(t *testing.T) {
14061406
},
14071407
} {
14081408
t.Run(tc.name, func(t *testing.T) {
1409-
res := maxResolutionFromSelectHints(tc.maxResolutionMillis, tc.hints)
1409+
res := maxResolutionFromSelectHints(tc.maxResolutionMillis, tc.hints.Range, tc.hints.Func)
14101410
testutil.Equals(t, tc.expected, res)
14111411
})
14121412
}

0 commit comments

Comments
 (0)