Block manager#377
Open
vslpsl wants to merge 4 commits into
Open
Conversation
Port reloadBlocks into a standalone pp/go/storage/block.Manager that reloads persisted blocks, applies retention via an injected tsdb.BlocksToDeleteFunc, and implements storage.Queryable/ChunkQueryable. Refactor pp-pkg/tsdb to a DB-free NewBlocksToDelete constructor that owns its retention metrics and limit gauges, and expose CatalogHeadsSize / CatalogHeadsExtraSize helpers. Add a tsdb.OpenBlocks wrapper. Co-authored-by: Cursor <cursoragent@cursor.com>
…locks This update adds the Blocks method to the Manager struct, which provides a snapshot of the currently loaded blocks, implementing the BlockSource interface. The method ensures thread-safe access to the blocks using read locks.
In server mode, stop opening tsdb.DB and instead run block.Manager (persisted block reads + retention) and block.Compactor (compaction). block.Manager is plugged into the fanout via a querier-only storage.Storage adapter; localStorage stays an empty stub. Replace the TSDB run-group actor with a lifecycle actor and drop the dead openDBWithMetrics and its obsolete TestTimeMetrics. Co-authored-by: Cursor <cursoragent@cursor.com>
vporoshok
reviewed
Jun 10, 2026
| } | ||
|
|
||
| // Close stops the reload loop and waits for it to finish. | ||
| func (m *Manager) Close() { |
Collaborator
There was a problem hiding this comment.
Close() currently waits for the loop to stop, but it does not close already loaded blocks in m.blocks. This can leave open block resources until process exit. Consider closing all currently loaded blocks under lock during shutdown.
vporoshok
reviewed
Jun 10, 2026
| stopc: make(chan struct{}), | ||
| stoppedc: make(chan struct{}), | ||
| } | ||
| go m.loop() |
Collaborator
There was a problem hiding this comment.
Potential regression: NewManager starts only the periodic loop, but there is no initial synchronous reload of existing blocks. Until the first ticker fire (up to 1 minute), manager.Blocks() is empty, so startup queries can miss persisted data and local StartTime for remote-read cutoff can be incorrect. Could we run one reload before exposing the manager as ready?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Why do we need it, and what problem does it solve?
Why do we need it in the patch release (if we do)?
Checklist
Changelog entries