-
Notifications
You must be signed in to change notification settings - Fork 653
feat(v2): metadata index retention policy #4148
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
Open
kolesnikovae
wants to merge
26
commits into
main
Choose a base branch
from
feat/metastore-index-truncation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
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
# Conflicts: # api/openapiv2/gen/phlare.swagger.json # pkg/experiment/ingester/segment_test.go
This reverts commit f9cc6fe.
kolesnikovae
commented
Jun 24, 2025
Comment on lines
+89
to
+93
logger: logger, | ||
config: cfg, | ||
store: s, | ||
shards: newShardCache(cfg.ShardCacheSize, s), | ||
blocks: newBlockCache(cfg.BlockReadCacheSize, cfg.BlockWriteCacheSize), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I finally removed the in-memory partition list – it's much cleaner now. Otherwise, we would eventually violate transaction isolation guarantees by exchanging state through the list
263d179
to
7ca1578
Compare
eac7b8c
to
208bf25
Compare
bd9d32a
to
59cfbd8
Compare
59cfbd8
to
a453844
Compare
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.
The change adds a new component that is responsible for enforcement of the retention policy.
It's implemented as follows:
I added a metric to keep track of the tombstone queue, and a metric to keep track of blocks deleted in compaction worker:
pyroscope_metastore_index_tombstones
(gauge)pyroscope_compaction_worker_blocks_deleted_total
(counter)The change introduces a new tenant override –
retention-period
. It works similarly tocompactor.blocks-retention-period
, but the latter takes precedence if both are set. In the future, we should consider setting a default retention policy; currently, it's unset, and many users aren't aware of this option. Regarding naming: I'm fine with adding a prefix likemetastore.
, but personally, I find it a bit confusing (same withcompactor.
. Users shouldn't need to know which component implements the option: this option is applied to the tenant, and not to the component. Anyway, I propose to carefully review the CLI and config options later, when we prepare for the release.To implement the change, I removed the in-memory list of partitions due to the risk of violating transaction isolation. This makes it much easier to reason about the version observed by both writers and readers. Performance testing with synthetic cases and real data showed no negative impact in practice.
The PR also fixes a bug where tombstones could be overwritten due to key collisions (based on Raft command index + append timestamp) at the storage level. This led to some leftover data, which will be cleaned up once a retention policy is enabled.
The change should be rolled out in two steps:
-metastore.index.cleanup-interval=1m
.The change is not forward-compatible: if rolled back, the old FSM won't be able to handle new "unknown" Raft commands: the node will crash trying to reply the WAL, and the rollback won't progress.