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

Enforce "max chunks per query" limit in ingesters too #4125

Conversation

pracucci
Copy link
Contributor

@pracucci pracucci commented Apr 26, 2021

What this PR does:
The -store.query-chunk-limit is only enforced in the long-term storage (but not ingesters). However, there are cases where this limit can actually be hit just querying ingesters, so I would like to apply the limit when fetching chunks from ingesters too.

However, if we extend -store.query-chunk-limit to apply to ingesters too, that could be considered a breaking change, so in this PR I'm proposing to deprecate -store.query-chunk-limit in favour of a new config option -querier.max-fetched-chunks-per-query, whose limit is applied both to ingesters and long-term storage.

Due to how the querying works in Cortex (ingesters and long-terms storage are queried separately) in this PR I'm proposing to keep it simple and apply the limit independently to ingesters and storage. This means that the total number of actual fetched chunks could be 2x the limit, being independently applied when querying ingesters and long-term storage. If accepted, this is something we may get back and eventually improve (in my opinion having the limit applied to ingesters too is better than having a true global limit, considering ingesters are currently unbounded, but I'm open to feedback).

Which issue(s) this PR fixes:
N/A

Checklist

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

@pracucci pracucci force-pushed the enforce-max-chunks-limit-in-ingesters-too branch from bbb1323 to 2cd47a1 Compare April 27, 2021 08:58
@pracucci pracucci requested review from pstibrany and gouthamve April 27, 2021 09:01
@pracucci pracucci marked this pull request as ready for review April 27, 2021 09:01
@pracucci pracucci changed the title Enforce -store.query-chunk-limit in ingesters Enforce "max chunks per query" limit in ingesters too Apr 27, 2021
@gouthamve
Copy link
Contributor

Can you please rebase against master to pull in #4137 and move the changelog entry to the top?

Copy link
Contributor

@pstibrany pstibrany left a comment

Choose a reason for hiding this comment

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

Good job, nothing to complain about. :)

func (d *Distributor) queryIngesterStream(ctx context.Context, userID string, replicationSet ring.ReplicationSet, req *ingester_client.QueryRequest) (*ingester_client.QueryStreamResponse, error) {
var (
maxChunksLimit = d.limits.MaxChunksPerQueryFromIngesters(userID)
totChunksCount = atomic.Int32{}
Copy link
Contributor

Choose a reason for hiding this comment

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

total? :) if you shorten both (chunksLimit, chunksCount) they will align nicely, and are expressive enough.

labels.MustNewMatcher(labels.MatchEqual, "foo", "bar"),
labels.MustNewMatcher(labels.MatchNotEqual, "who", "boh"),
},
expected: `{foo="bar",who!="boh"}`,
Copy link
Contributor

Choose a reason for hiding this comment

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

Test with __name__ label name would show that no special handling of that name is done.

…ier.max-fetched-chunks-per-query which is applied both to ingesters and long-term storage

Signed-off-by: Marco Pracucci <[email protected]>
Signed-off-by: Marco Pracucci <[email protected]>
Signed-off-by: Marco Pracucci <[email protected]>
@pracucci pracucci force-pushed the enforce-max-chunks-limit-in-ingesters-too branch from 31815c5 to a7e3cc8 Compare April 28, 2021 15:24
@pracucci
Copy link
Contributor Author

Thanks @pstibrany, I've addressed your feedback!

@pracucci pracucci enabled auto-merge (squash) April 28, 2021 15:26
@pracucci pracucci merged commit d382e1d into cortexproject:master Apr 28, 2021
@pracucci pracucci deleted the enforce-max-chunks-limit-in-ingesters-too branch April 29, 2021 06:39
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