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

querier: Use select params for mint and maxt #1012

Merged
merged 1 commit into from
Sep 23, 2018

Conversation

gouthamve
Copy link
Contributor

@gouthamve gouthamve commented Sep 19, 2018

TLDR; So turns out, if there was query like up offset 4w but start-end = 15s, we would end up getting all the chunks from start-4w to end. This PR makes sure only the relevant chunks are requested.

This is because when we create a Querier due to TSDB constraints (and maybe for other reasons), we need a single querier for a query. Which means if we X / Y where X has offset 4w and Y doesn't, the q.minTime, and q.maxTime will need to span the entire 4w.

But this is mitigated by setting the appropriate parameters on SelectParams which this PR makes sure we use.

Relevant promQL code:
https://github.com/prometheus/prometheus/blob/master/promql/engine.go#L465-L467
https://github.com/prometheus/prometheus/blob/master/promql/engine.go#L472
https://github.com/prometheus/prometheus/blob/master/promql/engine.go#L491-L495

Signed-off-by: Goutham Veeramachaneni <[email protected]>
@tomwilkie
Copy link
Contributor

I can't see anything wrong with this! Lets get it into dev...

func (q *chunkStoreQuerier) Select(_ *storage.SelectParams, matchers ...*labels.Matcher) (storage.SeriesSet, error) {
chunks, err := q.store.Get(q.ctx, model.Time(q.mint), model.Time(q.maxt), matchers...)
func (q *chunkStoreQuerier) Select(sp *storage.SelectParams, matchers ...*labels.Matcher) (storage.SeriesSet, error) {
chunks, err := q.store.Get(q.ctx, model.Time(sp.Start), model.Time(sp.End), matchers...)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this check that sp != nil ? Maybe it can't be today, but it seems safer to follow the general pattern.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only call by querier.go (Select), which includes that check. Calling this with nil should panic IMO. The only "root" queriers are the ones in querier.go and unified_querier.go, where the nil check need to be.

@gouthamve
Copy link
Contributor Author

This has been running in prod over the last couple of days and everything looks good!

@tomwilkie tomwilkie merged commit 91e5113 into cortexproject:master Sep 23, 2018
@tomwilkie tomwilkie deleted the use-select-params branch September 23, 2018 11:02
bwplotka added a commit to thanos-io/thanos that referenced this pull request Oct 22, 2019
This will definitely helps with offset queries.

Same was done on cortexproject/cortex#1012

Signed-off-by: Bartek Plotka <[email protected]>
bwplotka added a commit to thanos-io/thanos that referenced this pull request Oct 22, 2019
This will definitely helps with offset queries.

Same was done on cortexproject/cortex#1012

Signed-off-by: Bartek Plotka <[email protected]>
bwplotka added a commit to thanos-io/thanos that referenced this pull request Oct 22, 2019
This will definitely helps with offset queries.

Same was done on cortexproject/cortex#1012

Signed-off-by: Bartek Plotka <[email protected]>
brancz pushed a commit to thanos-io/thanos that referenced this pull request Oct 22, 2019
This will definitely helps with offset queries.

Same was done on cortexproject/cortex#1012

Signed-off-by: Bartek Plotka <[email protected]>
GiedriusS pushed a commit to thanos-io/thanos that referenced this pull request Oct 28, 2019
This will definitely helps with offset queries.

Same was done on cortexproject/cortex#1012

Signed-off-by: Bartek Plotka <[email protected]>
Signed-off-by: Giedrius Statkevičius <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants