Skip to content

Block manager#377

Open
vslpsl wants to merge 4 commits into
ppfrom
block-manager
Open

Block manager#377
vslpsl wants to merge 4 commits into
ppfrom
block-manager

Conversation

@vslpsl

@vslpsl vslpsl commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

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

  • The code is covered by unit tests.
  • e2e tests passed.
  • Documentation updated according to the changes.
  • Changes were tested in the Kubernetes cluster manually.

Changelog entries

 type: fix | feature | chore
 summary: <ONE-LINE of what effectively changes for a user>
 impact: <what to expect for users, possibly MULTI-LINE>, required if impact_level is high ↓
 impact_level: default | high | low

Vladimir Kavlakan and others added 3 commits June 8, 2026 15:56
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>
@vslpsl vslpsl requested a review from u-veles-a June 8, 2026 15:15
@vslpsl vslpsl requested a review from vporoshok as a code owner June 8, 2026 15:15
}

// Close stops the reload loop and waits for it to finish.
func (m *Manager) Close() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

done

stopc: make(chan struct{}),
stoppedc: make(chan struct{}),
}
go m.loop()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

done

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