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

Fixed --store.grpc.series-sample-limit #2858

Merged
merged 2 commits into from
Jul 20, 2020

Conversation

pracucci
Copy link
Contributor

@pracucci pracucci commented Jul 8, 2020

  • I added CHANGELOG entry for this change.
  • Change is not relevant to the end user.

Changes

In this PR I've changed the --store.grpc.series-sample-limit implementation to apply the limit to the sum of "samples" fetched across all queried blocks instead of individually apply the limit to each block.

Few notes:

  • Internally implemented as a chunks limiter (because that's what we limit on)
  • Introduced ChunksLimiterFactory to not pass a static limit to NewBucketStore because I would like to use it in Cortex too and in Cortex we have dynamic limits (limits can be reloaded live, without restarting the process)

Fixes #2845.

Verification

Existing + new unit tests.

Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

Looks perfect to me mod minor comments. Definitely good to merge, but would be nice to add TODO to maybe convert this to chunk bytes limiting. It's very normal in current TSDB state for chunks to be super small ):

Thanks!

@@ -722,12 +721,16 @@ func blockSeries(
s.refs = append(s.refs, meta.Ref)
}
if len(s.chks) > 0 {
if err := chunksLimiter.Reserve(uint64(len(s.chks))); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

We could potentially limit chunk bytes instead TBH, but this is good for a start

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Or both. In Cortex we would need by count :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Opened an issue: #2861

pkg/store/limiter.go Outdated Show resolved Hide resolved
pkg/store/limiter.go Show resolved Hide resolved
if reserved := atomic.AddUint64(&l.reserved, num); reserved > l.limit {
// We need to protect from the counter being incremented twice due to concurrency
// while calling Reserve().
l.failedOnce.Do(l.failedCounter.Inc)
Copy link
Member

Choose a reason for hiding this comment

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

👍

@pracucci
Copy link
Contributor Author

pracucci commented Jul 8, 2020

Thanks @bwplotka for your feedback. I should have addressed the comments and fixed the doc.

Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

Perfect, super nice change! Extremely useful bugfix for users! 💪

@bwplotka
Copy link
Member

Looks like my manual rebase through Github UI (there were conflicts) was not successful.. 😢 I tried ;p

Signed-off-by: Marco Pracucci <[email protected]>
@bwplotka bwplotka merged commit 82cca56 into thanos-io:master Jul 20, 2020
@bwplotka
Copy link
Member

Thanks!

@pracucci pracucci deleted the fix-series-sample-limit branch July 21, 2020 07:14
@mneverov mneverov mentioned this pull request Sep 24, 2020
2 tasks
@xiaozongyang
Copy link

Hi @pracucci,
I'm using this feature in my production environment, thx for you great job!

And I'm wondering that do we have some metrics about loaded/fetched samples per-query? So we can determine a query is rejected by this series limit or other reason.

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.

Thanos store: improve series-sample-limit
3 participants