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

Return Canceled when a LabelNames or LabelValues request to a store-gateway is cancelled by the caller, and return Internal otherwise for all requests. #4061

Merged
merged 2 commits into from
Feb 3, 2023

Conversation

charleskorn
Copy link
Contributor

@charleskorn charleskorn commented Jan 24, 2023

What this PR does

See #4007 for background.

Which issue(s) this PR fixes or relates to

Follow on from #4007.

Checklist

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

@pracucci pracucci self-requested a review January 24, 2023 15:42
Copy link
Collaborator

@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.

The changes LGTM!

I've opened this as a draft because the tests that I've added in this PR currently fail ~50% of the time due to a race here where the context cancellation competes with the loading of expanded postings. I can't find a nice way to make these tests robust - would love some suggestions.

An option is to hit the context canceled in a different path. For example, you could configure the store WithIndexCache() and pass an implementation which returns the context.Canceled error. This way you don't have to directly pass a canceled context to the LabelNames() function itself.

@charleskorn
Copy link
Contributor Author

An option is to hit the context canceled in a different path. For example, you could configure the store WithIndexCache() and pass an implementation which returns the context.Canceled error. This way you don't have to directly pass a canceled context to the LabelNames() function itself.

Good idea. Unfortunately, we log + ignore errors from caches, so the best other place to do this seems to be in the object storage implementation, which is what I've done here.

I'm wondering whether it makes sense to modify github.com/thanos-io/objstore/providers/filesystem.Bucket to respect context cancellations, which would remove the need for cancellationRespectingBucket here and also bring the implementation in line with how other object storage implementations behave with respect to context cancellations - what do you think?

@charleskorn charleskorn force-pushed the charleskorn/store-gateway-return-canceled branch from 7c88733 to 3b1cb43 Compare January 25, 2023 00:34
@pracucci
Copy link
Collaborator

I'm wondering whether it makes sense to modify github.com/thanos-io/objstore/providers/filesystem.Bucket to respect context cancellations, which would remove the need for cancellationRespectingBucket here and also bring the implementation in line with how other object storage implementations behave with respect to context cancellations - what do you think?

Would be a cleaner solution. Let's try to offer the upstream change to filesystem.Bucket and see if they accept it.

@charleskorn
Copy link
Contributor Author

I'm wondering whether it makes sense to modify github.com/thanos-io/objstore/providers/filesystem.Bucket to respect context cancellations, which would remove the need for cancellationRespectingBucket here and also bring the implementation in line with how other object storage implementations behave with respect to context cancellations - what do you think?

Would be a cleaner solution. Let's try to offer the upstream change to filesystem.Bucket and see if they accept it.

I've raised thanos-io/objstore#43, let's see what they think.

@charleskorn
Copy link
Contributor Author

thanos-io/objstore#43 has been merged 🎉. Once #4136 is merged, I'll update this PR to take advantage of it.

…ateway is cancelled by the caller, and return Internal otherwise.

See #4007 for explanation.
@charleskorn charleskorn force-pushed the charleskorn/store-gateway-return-canceled branch from 3b1cb43 to 94b0b7c Compare February 3, 2023 00:08
@charleskorn charleskorn marked this pull request as ready for review February 3, 2023 00:08
@charleskorn charleskorn requested a review from a team as a code owner February 3, 2023 00:08
Copy link
Collaborator

@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.

Nice, thanks!

@pracucci pracucci merged commit fe0226b into main Feb 3, 2023
@pracucci pracucci deleted the charleskorn/store-gateway-return-canceled branch February 3, 2023 04:40
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.

2 participants