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

Store-gateway: allow postings scans to be interrupted #8154

Merged
merged 4 commits into from
May 16, 2024
Merged

Conversation

bboreham
Copy link
Contributor

What this PR does

If the filter operation is expensive, e.g. a large regexp, and the posting has a lot of values, filtering can many seconds. Check the context for cancellation every 1024 values.

Which issue(s) this PR fixes or relates to

Same issue as grafana/mimir-prometheus#633, but store-gateway does its own index scans.

Checklist

  • Tests updated.
  • NA Documentation added.
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX].
  • NA about-versioning.md updated with experimental features.

If the filter operation is expensive, e.g. a large regexp, and the
posting has a lot of values, filtering can many seconds.
Check the context for cancellation every 1024 values.

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
@bboreham bboreham requested a review from a team as a code owner May 16, 2024 11:13
Copy link
Contributor

@krajorama krajorama left a comment

Choose a reason for hiding this comment

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

Looks good, I'd suggest to add some unit tests.

for d.Err() == nil && !currEntry.isLast {
if count%checkContextEveryNIterations == 0 && ctx.Err() != nil {
return nil, ctx.Err()
Copy link
Contributor

Choose a reason for hiding this comment

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

can we wrap the error so we have a bit more details? Also using context.Cause instead of ctx.Err() would give even more details

…ancel

Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
Copy link
Contributor

@56quarters 56quarters left a comment

Choose a reason for hiding this comment

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

LGTM with some minor comments. It'd be nice to implement @dimitarvdimitrov 's
suggestions but I understand this is urgent-ish.

krajorama and others added 2 commits May 16, 2024 18:04
Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
@krajorama krajorama merged commit 04e6b7f into main May 16, 2024
29 checks passed
@krajorama krajorama deleted the postings-context branch May 16, 2024 17:57
francoposa pushed a commit that referenced this pull request May 27, 2024
* Store-gateway: allow postings scans to be interrupted

If the filter operation is expensive, e.g. a large regexp, and the
posting has a lot of values, filtering can many seconds.
Check the context for cancellation every 1024 values.

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
Co-authored-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
Co-authored-by: George Krajcsovits <krajorama@users.noreply.github.com>
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.

4 participants