Ingester: re-validate ownership before evicting non-owned series - #16534
Draft
duricanikolic wants to merge 2 commits into
Draft
Ingester: re-validate ownership before evicting non-owned series#16534duricanikolic wants to merge 2 commits into
duricanikolic wants to merge 2 commits into
Conversation
Signed-off-by: Yuri Nikolic <durica.nikolic@grafana.com>
Signed-off-by: Yuri Nikolic <durica.nikolic@grafana.com>
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.
What this PR does
Fixes a race condition in the ingester's early compaction of non-owned series (
-ingester.early-compaction-non-owned-series-enabled).When a series is no longer owned by an ingester, it is queued for eviction and eventually flushed to a block once its grace period expires. If the ingester regains ownership of the series before the grace period expires, the eviction path does not re-check ownership before flushing it. Instead, it relies on the potentially stale ownership state from when the series was originally queued.
As a result, a series that has become owned again and received new samples in the meantime could still be evicted from the head, causing those samples to be silently dropped.
The race exists because ownership reconciliation and early compaction run independently. The owned-series service periodically reconciles ownership, while the compaction loop processes queued series on a separate schedule. There is no guarantee that ownership will be reconciled before a queued series becomes eligible for eviction.
This PR fixes the race by making
compactBlocksDueToNonOwnedSeriesre-evaluate ownership immediately before processing series queued for eviction. For each tenant with queued series, it refreshes their ownership status against the ingester's current view before consuming the queue:The additional ownership check is performed only for tenants with series queued for eviction, so tenants without pending early compaction incur no additional overhead.
A new unit test reproduces the race and verifies that a series that becomes owned again is not evicted. Existing tests covering early compaction continue to pass unchanged.
Which issue(s) this PR fixes or relates to
Fixes #
Checklist
CHANGELOG.mdupdated - the order of entries should be[CHANGE],[FEATURE],[ENHANCEMENT],[BUGFIX]. If changelog entry is not needed, please add thechangelog-not-neededlabel to the PR.about-versioning.mdupdated with experimental features.