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: Move eager loading to BucketStore #8602

Merged

Conversation

dimitarvdimitrov
Copy link
Contributor

@dimitarvdimitrov dimitarvdimitrov commented Jul 4, 2024

This is the third PR for #8389

What this PR does

This PR does one major change: Move eager loading from ReaderPool to BucketStore.

The problem with keeping eager loading in the ReaderPool is that it needs to have the list of previously loaded blocks injected. This is hard if we want to move the snapshotter and index reader pool to being services.

The PR also slightly changes the Snapshotter to receive its dependency (BlocksLoader which has the list of currently loaded blocks) via the constructor as opposed to via each snapshot iteration. This is now possible because there is no circular dependency between the Snapshotter and the ReaderPool (the snapshotter needed to pool to know what's loaded; the pool needed the snapshotter to know what to eager load).

Which issue(s) this PR fixes or relates to

related to #8389

Checklist

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

@dimitarvdimitrov dimitarvdimitrov force-pushed the dimitar/st-gw/move-eager-loading-to-bucket-store branch from d4c5ba0 to 00e664c Compare July 4, 2024 14:02
@dimitarvdimitrov dimitarvdimitrov force-pushed the dimitar/st-gw/snapshotter-service branch from fb8d68e to 9725277 Compare July 4, 2024 18:37
@dimitarvdimitrov dimitarvdimitrov force-pushed the dimitar/st-gw/move-eager-loading-to-bucket-store branch from 00e664c to 4a2976a Compare July 8, 2024 18:52
Base automatically changed from dimitar/st-gw/snapshotter-service to main July 9, 2024 16:39
Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>

Move eager loading from LazyBinaryReader to BucketStore

Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
Use correct eager loading config

Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
@dimitarvdimitrov dimitarvdimitrov force-pushed the dimitar/st-gw/move-eager-loading-to-bucket-store branch from 4a2976a to e4828c7 Compare July 10, 2024 15:44
Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
@dimitarvdimitrov
Copy link
Contributor Author

this is now ready for a review

@dimitarvdimitrov dimitarvdimitrov marked this pull request as ready for review July 10, 2024 16:01
@dimitarvdimitrov dimitarvdimitrov requested a review from a team as a code owner July 10, 2024 16:01
Copy link
Contributor

@narqo narqo left a comment

Choose a reason for hiding this comment

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

I've left a couple of small comments, but the all on the "cosmetics" side of things. Overall, the changes look good to me and I don't think my comments must block the PR 🔥

pkg/storegateway/gateway.go Outdated Show resolved Hide resolved
pkg/storegateway/bucket.go Outdated Show resolved Hide resolved
Comment on lines 375 to 384
previouslyLoadedBlocks, err := indexheader.RestoreLoadedBlocks(s.dir)
if err != nil {
level.Warn(s.logger).Log(
"msg", "loading the list of index-headers from snapshot file failed; not eagerly loading index-headers for tenant",
"dir", s.dir,
"err", err,
)
// Don't fail initialization. If eager loading doesn't happen, then we will load index-headers lazily.
// Lazy loading which is slower, but not worth failing startup for.
}
Copy link
Contributor

Choose a reason for hiding this comment

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

How about we move this chunk inside s.loadBlocks (and maybe rename this method to s.restorePreviousBlocks)? We don't need to do it if EagerLoadingStartupEnabled is disabled. And also this will make the piece about "not failing the initialization" less awkward (IMHO).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

after we run syncBlocks the snapshotter will be running, so there's a theoretical race between the snapshotter and reading the snapshot from before the shutdown. It's not obvious, so I now added a comment explaining this and moved this whole thing into a function.

But if you have ideas for how to make this better I can do it

Copy link
Contributor

Choose a reason for hiding this comment

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

It makes more sense now, thanks for explaining. I'm ok to stick to the current version. I think, the comments you've added makes it clear 👍

Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
Copy link
Contributor

@narqo narqo left a comment

Choose a reason for hiding this comment

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

It's even better now 🔥🔥

@dimitarvdimitrov dimitarvdimitrov merged commit f89d319 into main Jul 12, 2024
29 checks passed
@dimitarvdimitrov dimitarvdimitrov deleted the dimitar/st-gw/move-eager-loading-to-bucket-store branch July 12, 2024 11:20
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