Skip to content

Reject small subquery step size in query frontend #5323

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

Merged
merged 7 commits into from
May 9, 2023

Conversation

yeya24
Copy link
Contributor

@yeya24 yeya24 commented May 5, 2023

What this PR does:

In Prometheus, there is a step size check to make sure we don't have too many samples for a series for range query because it takes step and range parameters https://github.com/prometheus/prometheus/blob/main/web/api/v1/api.go#L503.

However, there is no such check for subquery, which makes subqueries to have very large steps such as up[30d:1s]. This could easily OOM kill queriers.

This pr adds the same step size check in QFE to reject such queries.

Which issue(s) this PR fixes:
Fixes #

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

yeya24 added 5 commits May 5, 2023 00:59
Signed-off-by: Ben Ye <[email protected]>
Signed-off-by: Ben Ye <[email protected]>
Signed-off-by: Ben Ye <[email protected]>
Signed-off-by: Ben Ye <[email protected]>
Signed-off-by: Ben Ye <[email protected]>
)

var (
ErrSubQueryStepTooSmall = "exceeded maximum resolution of %d points per timeseries in subquery. Try decreasing the step size of your subquery"
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you meant to recommend "increasing" the step size? or decreasing the "number of steps"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. I updated it to increasing the step size.

Comment on lines 53 to 59
{
name: "two subqueries within functions",
query: "sum_over_time(up[60m:]) + avg_over_time(test[5m:1m])",
maxStep: 10,
defaultStep: time.Second,
err: httpgrpc.Errorf(http.StatusBadRequest, ErrSubQueryStepTooSmall, 10),
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we also add a test for two subqueries that's within the step limit?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. Added another test case.

Copy link
Contributor

@justinjung04 justinjung04 left a comment

Choose a reason for hiding this comment

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

Thank you! LGTM

@alanprot
Copy link
Member

alanprot commented May 9, 2023

THANKS! LGTM

@yeya24 yeya24 merged commit f1d3d1e into cortexproject:master May 9, 2023
@yeya24 yeya24 deleted the step-size-check branch May 9, 2023 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants