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

Compactor: do not issue object storage HEAD API calls to check if cached meta.json files still exist #5063

Merged
merged 4 commits into from
May 25, 2023

Conversation

pracucci
Copy link
Collaborator

@pracucci pracucci commented May 23, 2023

What this PR does

The compactor issue a "object exists" API call for every block of each tenant every -compactor.compaction-interval. If you run a Mimir cluster with a large number of tenants (order of tens of thousands) and 1 year blocks retention, this can causes a very high number of API calls (order of hundred of millions per day). This PR removes such call.

The rationale of the change introduced in this PR is better explained here, but can be summarised as:

  • Before this PR, we filtered out blocks marked for deletion after synching their metas. However, there's no need to do it that late, since we don't care about blocks marked for deletion, so in this PR I moved that filtering upfront. The new logic is: list blocks in the bucket, filter out the ones marked for deletion, sync meta.json files for the remaining ones.
  • meta.json files are immutable. Before this PR, the only reason why we checked for meta.json existence was to find out if a block was deleted (or deletion was in progress) between the "list blocks" operations and their sync (which was calling Exists() on each block's meta.json). After this PR, where the call to Exists() as been removed, this case shouldn't be a real issue because we filter out the blocks that were marked for deletion before we start listing blocks in the bucket. The block.Delete() also guarantees that the deletion mark is the last file to be removed when deleting a block (and meta.json is the first one), so this should reduce the race conditions we may have.

Which issue(s) this PR fixes or relates to

Fixes #5056

Checklist

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

@pracucci pracucci force-pushed the remove-metafetcher-exists-call branch from 6f3dba5 to 8e4b3e3 Compare May 25, 2023 08:19
Signed-off-by: Marco Pracucci <[email protected]>
@pracucci pracucci marked this pull request as ready for review May 25, 2023 08:32
@pracucci pracucci requested a review from a team as a code owner May 25, 2023 08:32
Copy link
Member

@pstibrany pstibrany left a comment

Choose a reason for hiding this comment

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

After the artillery preparation in previous PRs, this was a breeze. Nice work.

pkg/storage/tsdb/block/fetcher.go Outdated Show resolved Hide resolved
@@ -314,6 +343,12 @@ func (f *MetaFetcher) fetchMetadata(ctx context.Context) (interface{}, error) {
return nil
}

// If requested, skip any block marked for deletion.
if _, marked := markedForDeletion[id]; excludeMarkedForDeletion && marked {
Copy link
Member

Choose a reason for hiding this comment

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

nit: we don't need to check for excludeMarkedForDeletion again. If it's false then markedForDeletion will be nil (ie. empty map).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The reason why I added the check here as well is to make the code more obvious when reading it. Given it doesn't add extra complexity, I would keep it.

CHANGELOG.md Outdated Show resolved Hide resolved
pracucci and others added 2 commits May 25, 2023 11:43
Signed-off-by: Marco Pracucci <[email protected]>
@pracucci
Copy link
Collaborator Author

I completed the manual tests on this PR. Going to merge it.

@pracucci pracucci merged commit 5a795c3 into main May 25, 2023
@pracucci pracucci deleted the remove-metafetcher-exists-call branch May 25, 2023 11:03
@charleskorn charleskorn mentioned this pull request Jun 21, 2023
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.

Reduce number of object storage HEAD api calls issued by compactor
2 participants