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

Limit queried chunks by bytes #3089

Closed
wants to merge 2 commits into from

Conversation

mneverov
Copy link
Contributor

@mneverov mneverov commented Aug 27, 2020

Fixes: #2861

Signed-off-by: Max Neverov [email protected]

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

Changes

Add possibility to limit queried chunks by bytes via store.grpc.series-sample-size-limit flag.

@mneverov mneverov changed the title Add new flag description WIP: Limit queried chunks by bytes Aug 28, 2020
@@ -769,6 +774,10 @@ func blockSeries(
return nil, nil, errors.Wrap(err, "preload chunks")
}

if err := chunksSizeLimiter.Reserve(uint64(chunkr.stats.seriesFetchedSizeSum)); 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.

As per your question:

Another question is is it a proper way to limit based on a chunk reader stats? https://github.com/thanos-io/thanos/pull/3089/files#diff-a75f50a9f5bf5b21a862e4e7c6bd1576R777
Or is it better to pass the limiter to the preload function?

That's a good one, it really depends on one thing: Do we want to return partial data if limit is exceeded or fail everything? (:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My take on that is that a user might be surprised when find out that the returned response was partial.
It might make sense to create a config for that and apply for both: limiting by a number of samples and by byte size.

Copy link
Member

Choose a reason for hiding this comment

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

Oh yes, we have warnings for that. Everything with warning is assumed partial - then querier decide if it's error or not with partialResponseStrategy request option (:

@mneverov mneverov force-pushed the chunk_byte_limit branch 2 times, most recently from dce3725 to 666479a Compare September 24, 2020 19:45
@mneverov
Copy link
Contributor Author

mneverov commented Sep 24, 2020

To the reviewer:
A new bucket store constructor name suggestions are greatly appreciated.
I reused a chunk reader stats instead of passing the limiter to the preload function because it was refactored out in #2858

@mneverov mneverov changed the title WIP: Limit queried chunks by bytes Limit queried chunks by bytes Sep 24, 2020
@mneverov mneverov marked this pull request as ready for review September 24, 2020 20:07
pkg/store/bucket.go Outdated Show resolved Hide resolved
@@ -68,6 +68,10 @@ func registerStore(app *extkingpin.App) {
"Maximum amount of samples returned via a single Series call. The Series call fails if this limit is exceeded. 0 means no limit. NOTE: For efficiency the limit is internally implemented as 'chunks limit' considering each chunk contains 120 samples (it's the max number of samples each chunk can contain), so the actual number of samples might be lower, even though the maximum could be hit.").
Default("0").Uint()

maxSampleSize := cmd.Flag("store.grpc.series-sample-size-limit",
"Maximum size of samples returned via a single Series call. The Series call fails if this limit is exceeded. 0 means no limit.").
Copy link
Contributor

Choose a reason for hiding this comment

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

I would clarify what's the unit here. Bytes?

)

chunksSizeLimiter, err = chunksSizeLimiter.NewWithFailedCounterFrom(chunksLimiter)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you clarify why you need NewWithFailedCounterFrom()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pracucci thanks for reviewing this.
Chunks limiter and chunks size limiter should have common failedOnce to avoid concurrent update of the failedCounter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

more info on that: store does not know at the moment of ChunksLimit and ChunksSizeLimit creation what metrics will be used. Metrics are the part of the BucketStore. That is why store operates limiter factories and bucket creates new chunk size limiter with the sync.Once shared between limiters. Hope that helps

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 NewWithFailedCounterFrom() is a bit overengineered.

There's no problem updating a metric concurrently, but we may want to distinguish the reason why a query was dropped. An option may be adding a "reason" label to queriesDropped and passing s.metrics.queriesDropped.WithLabelValues("<reason>") to both factories.

@mneverov mneverov force-pushed the chunk_byte_limit branch 2 times, most recently from 0aec4b0 to abdb25f Compare October 25, 2020 18:04
…ne; amend the new config description

Signed-off-by: Max Neverov <[email protected]>
@stale
Copy link

stale bot commented Dec 26, 2020

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale label Dec 26, 2020
@stale stale bot closed this Jan 2, 2021
@kakkoyun
Copy link
Member

kakkoyun commented Jan 5, 2021

Hey @mneverov, shall we reopen this? Do you plan to work on it?

@mneverov
Copy link
Contributor Author

mneverov commented Jan 5, 2021

hi @kakkoyun,
I created this PR in August, asked a couple of times for review, did some fixes after review.
I do not know if this still needed. From my point of view someone from the main contributors should check this and merge/reject/close.
Will be happy to work again on this if you, @bwplotka, or @pracucci have comments.

@kakkoyun
Copy link
Member

kakkoyun commented Jan 5, 2021

@mneverov 👍 Reopening it and passing it to @bwplotka @pracucci. We can either merge if it's good to go or close it again.

@kakkoyun kakkoyun reopened this Jan 5, 2021
@stale stale bot removed stale labels Jan 5, 2021
Base automatically changed from master to main February 26, 2021 16:30
Copy link
Contributor

@pracucci pracucci left a comment

Choose a reason for hiding this comment

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

Sorry for the extreme low review. Overall changes LGTM, but I left a couple of comments.

)

chunksSizeLimiter, err = chunksSizeLimiter.NewWithFailedCounterFrom(chunksLimiter)
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 NewWithFailedCounterFrom() is a bit overengineered.

There's no problem updating a metric concurrently, but we may want to distinguish the reason why a query was dropped. An option may be adding a "reason" label to queriesDropped and passing s.metrics.queriesDropped.WithLabelValues("<reason>") to both factories.


// NewBucketStoreWithOptions creates a new bucket backed store that implements the store API against
// an object store bucket. It is optimized to work against high latency backends.
func NewBucketStoreWithOptions(
Copy link
Contributor

Choose a reason for hiding this comment

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

@bwplotka What do you think about this? I've mixed feelings about it, just to avoid adding another argument to NewBucketStore(). Maybe we can rollback options in this PR and follow up the discussion about functional options in #3931?


// NewBucketStoreWithOptions creates a new bucket backed store that implements the store API against
// an object store bucket. It is optimized to work against high latency backends.
func NewBucketStoreWithOptions(
Copy link
Contributor

Choose a reason for hiding this comment

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

@bwplotka What do you think about this? I've mixed feelings about it, just to avoid adding another argument to NewBucketStore(). Maybe we can rollback options in this PR and follow up the discussion about functional options in #3931?

@mneverov
Copy link
Contributor Author

hi @pracucci ,
thanks for the review! All comments are valid.
It's been a while since the PR was submitted and I stuck in rebasing master branch. I think it is easier to close this PR and reimplement the functionality on top of updated bucket.go.
Sorry you wasted your time on this, I should have closed it long time ago.

@mneverov mneverov closed this Mar 31, 2021
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.

Store: limit queried chunks by bytes
5 participants