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

S3: Return context cancellation from Iter when applicable #62

Merged
merged 1 commit into from
Jul 10, 2023

Conversation

56quarters
Copy link
Contributor

@56quarters 56quarters commented Jul 6, 2023

Changes

This PR returns ctx.Err() from the S3 Iter method instead of nil after exhausting the ListObjects channel.

When the context passed to the S3 Iter method is cancelled, the underlying Minio client sometimes immediately closes the results channel and returns without sending the ctx.Err() error. Depending on when exactly the context is cancelled, this can result in the Iter method not returning any results and not returning an error indicating what happened.

Discovered while debugging grafana/mimir#5433

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

Verification

Tested via Mimir end-to-end test used to reproduce the issue. The S3 Bucket implementation uses the concrete Minio Client instead of an interface so writing a unit test would be a challenge without making quite a few changes to the Bucket. I can do that if you'd like but it seemed like a lot of churn for a small change.

When the context passed to the S3 Iter method is cancelled, the underlying
Minio client sometimes immediately closes the results channel and returns
without sending the `ctx.Err()` error. Depending on when exactly the context
is cancelled, this can result in the `Iter` method not returning any results
_and_ not returning an error indicating what happened.

Discovered while debugging grafana/mimir#5433

Signed-off-by: Nick Pillitteri <nick.pillitteri@grafana.com>
@56quarters 56quarters marked this pull request as ready for review July 7, 2023 14:13
Copy link
Member

@GiedriusS GiedriusS left a comment

Choose a reason for hiding this comment

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

LGTM, however, could you please also create an upstream issue in minio-go? It seems like this is something that could be solved there. I also saw this in prod where remote object storage was having problems and sometimes the meta fetcher returned 0 metas with no errors. This is probably the cause. Haven't had time to dig into this myself.

@56quarters
Copy link
Contributor Author

LGTM, however, could you please also create an upstream issue in minio-go? It seems like this is something that could be solved there. I also saw this in prod where remote object storage was having problems and sometimes the meta fetcher returned 0 metas with no errors. This is probably the cause. Haven't had time to dig into this myself.

Opened an issue, thanks!

@GiedriusS GiedriusS merged commit 47c0118 into thanos-io:main Jul 10, 2023
7 checks passed
56quarters added a commit to grafana/mimir that referenced this pull request Jul 10, 2023
Specifically to pull in thanos-io/objstore#62 which fixes an issue where
all store-gateways unloaded all blocks due to a badly timed shutdown.

The library has removed the thanos_ prefix from metrics which our dashboards
rely on. I've worked around this change by adding the prefix back.

Fixes #5433

Signed-off-by: Nick Pillitteri <nick.pillitteri@grafana.com>
@56quarters 56quarters deleted the iter-context branch July 10, 2023 22:16
56quarters added a commit to grafana/mimir that referenced this pull request Jul 11, 2023
Specifically to pull in thanos-io/objstore#62 which fixes an issue where
all store-gateways unloaded all blocks due to a badly timed shutdown.

The library has removed the thanos_ prefix from metrics which our dashboards
rely on. I've worked around this change by adding the prefix back.

Fixes #5433

Signed-off-by: Nick Pillitteri <nick.pillitteri@grafana.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.

2 participants