grafana / mimir

Grafana Mimir provides horizontally scalable, highly available, multi-tenant, long-term storage for Prometheus.
https://grafana.com/oss/mimir/
GNU Affero General Public License v3.0
4.07k stars 519 forks source link

store-gateway: refactor BucketStore to have proper module lifecycle #8389

Closed dimitarvdimitrov closed 2 months ago

dimitarvdimitrov commented 3 months ago

The BucketStore and the ReaderPool it uses need to start goroutines. It's hard to keep track of those and hard to clean them up. #8281 introduced another background goroutine. See https://github.com/grafana/mimir/blob/36f96f19bde5d6e5552600b25893244971b007c8/pkg/util/test/leak.go#L27-L30

The store-gateway would be easier to navigate and less prone to bugs if the BucketStore has proper lifecycle functions like start, run, and stop. Like a lot of other internal services.

This issue is a follow-up for this comment thread https://github.com/grafana/mimir/pull/8281#discussion_r1638174462

dimitarvdimitrov commented 3 months ago

related comment from @pracucci https://github.com/grafana/mimir/pull/8281#discussion_r1642887792

dimitarvdimitrov commented 3 months ago

The changes became slightly long and hard to follow. I plan to open a few PRs for this