mimir icon indicating copy to clipboard operation
mimir copied to clipboard

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

Open charleskorn opened this issue 2 years ago • 3 comments

What this PR does

See #4007 for background.

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.

Which issue(s) this PR fixes or relates to

Follow on from #4007.

Checklist

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

charleskorn avatar Jan 24 '23 05:01 charleskorn

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 avatar Jan 25 '23 00:01 charleskorn

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.

pracucci avatar Jan 25 '23 10:01 pracucci

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 https://github.com/thanos-io/objstore/pull/43, let's see what they think.

charleskorn avatar Jan 27 '23 00:01 charleskorn

https://github.com/thanos-io/objstore/pull/43 has been merged 🎉. Once https://github.com/grafana/mimir/pull/4136 is merged, I'll update this PR to take advantage of it.

charleskorn avatar Feb 02 '23 00:02 charleskorn