Repository navigation
Conversation
alanprot
force-pushed
the
ownership-own-zone
branch
from
November 21, 2026 04:35
b332739 to
5ecc526
Compare
alanprot
force-pushed
the
ownership-own-zone
branch
2 times, most recently
from
November 21, 2026 05:50
443f067 to
130fc87
Compare
The refresher recomputed every tenant's share on each 10s refresh, building a shuffle-shard subring per tenant, and the fed ring cached every subring it built. With 3,000 ingesters that was over a second per 1,000 tenants on each refresh and hundreds of MB of cached subrings, although a heartbeat changes no share. Keep one share per tenant. The heartbeat delegate bumps a generation only when an instance joins or leaves this ingester's zone, changes its tokens, or becomes or stops being READONLY, or when the number of zones changes, which sets how many members each zone gets. Shard picks and ownership are per zone, so other changes in other zones do not move this ingester's shares. The refresher recomputes a tenant when the generation or the tenant's shard size changes, or when the tenant switches between its subring and the whole ring as the instance count crosses its shard size. The ring is built with SubringCacheDisabled, since a subring is now built only to read one share. Shares are computed with WriteNoExtend: every instance owns the ranges of its tokens except READONLY instances, whose ranges go to the next instance in their zone. That is the same rule the recompute trigger follows, and it matches -distributor.extend-writes=false. With extend-writes on, the ranges of JOINING, LEAVING and PENDING instances are not counted for the instances writes go to instead. The ingester no longer needs the distributor's extend-writes setting. Signed-off-by: Alan Protasio <alanprot@gmail.com>
No change in behaviour. The condition under which ShuffleShard returns the whole ring instead of a subring becomes ShuffleShardUsesWholeRing, so the ingester's ownership refresher, which recomputes a tenant's share when the condition flips, uses the same rule as ShuffleShard. Signed-off-by: Alan Protasio <alanprot@gmail.com>
alanprot
force-pushed
the
ownership-own-zone
branch
from
November 21, 2026 05:58
130fc87 to
e041da2
Compare
ZonalOwnership took the write operation and left out the tokens of every instance it extends the replica set past. Its only caller now always asks for WriteNoExtend, so drop the parameter: every instance owns the ranges of its tokens except READONLY instances, whose ranges go to the next instance in their zone. ZonalOwnership was added in cortexproject#7954 and is unreleased. The cache becomes one map, cleared when tokens change or an instance becomes or stops being READONLY, which RingCompare reports as EqualButReadOnly. A heartbeat or any other state change no longer clears it. A READONLY change also resets the shuffle-shard subring cache, so cached subrings no longer need their own check. Signed-off-by: Alan Protasio <alanprot@gmail.com>
alanprot
force-pushed
the
ownership-own-zone
branch
from
November 21, 2026 06:10
cee6acc to
f15f1e8
Compare
This branch has not been deployed
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:
Follow-up to #7954. With
-ingester.use-ring-ownership-for-limits, the ingester keeps only each tenant's ownership share and recomputes it only when a ring change can move it. The ring package gainsShuffleShardUsesWholeRingand a simplerZonalOwnership; the rest is inpkg/ingester.In #7954 the refresher recomputed every tenant's share on each 10 s refresh, building a shuffle-shard subring per tenant with
ShuffleShard(tenant, size).ZonalOwnership(op)[me], and the fed ring cached every subring it built. A heartbeat changes no share, but at 3,000 ingesters that was over a second of CPU per 1,000 tenants on each refresh, and hundreds of MB of cached subrings.Changes
Keep only the share. The refresher keeps one share per tenant, still computed by
ShuffleShardandZonalOwnership. The ring used for it is built with the existingSubringCacheDisabled, so subrings are built only to read one share and then dropped.Recompute only when the share can change. The heartbeat delegate bumps a generation when, in this ingester's zone, an instance joins or leaves, changes its tokens, or becomes or stops being READONLY (shuffle-shard picks skip READONLY instances), or when the number of zones changes (it sets how many members each zone gets). Shard picks and ownership are per zone, so other changes in other zones cannot move this ingester's shares. The refresher recomputes a tenant when the generation or the tenant's shard size changes, or when the tenant switches between its subring and the whole ring because the instance count crossed its shard size.
One ownership rule. Every instance owns the ranges of its tokens except READONLY instances, whose ranges go to the next instance in their zone. It is the same rule the recompute trigger follows, and it matches
-distributor.extend-writes=false. With extend-writes on, the ranges of JOINING, LEAVING and PENDING instances are not counted for the instances writes go to instead. The ingester no longer needs the distributor's extend-writes setting, soConfig.DistributorExtendWrites(added in Ingester: convert global limits to local using actual ring ownership #7954) is removed.ZonalOwnershipwithout an operation (pkg/ring). It was added in Ingester: convert global limits to local using actual ring ownership #7954 and is unreleased, and its only caller always asked forWriteNoExtend, so the parameter is dropped and the rule lives in the ring: every instance owns the ranges of its tokens except READONLY instances. Its cache becomes one map, cleared when tokens change or an instance becomes or stops being READONLY (RingComparereports that asEqualButReadOnly). A heartbeat or any other state change no longer clears it, and since a READONLY change also resets the subring cache, cached subrings need no check of their own.ShuffleShardUsesWholeRing(pkg/ring, no behaviour change). The condition under whichShuffleShardreturns the whole ring instead of a subring is extracted, so the refresher andShuffleSharduse the same rule.Cost at 3,000 ingesters × 128 random tokens, 1,000 tenants with shard size 30
The comparison runs in the heartbeat callback over this zone's instances. The subring cache, 43 MB for these 1,000 tenants and 214–401 MB for larger cases, no longer exists.
Tests
ShuffleShardcalls for the same tenant return different subrings.TestIngesterRingOwnershipLimits(9 ingesters, Docker) stores the same series as before: 3991 and 3979 of a 4000 limit.go test -race -tags slicelabels ./pkg/ingester/ -run 'Ownership|Limiter' -count=5passes; golangci-lint is clean.Which issue(s) this PR fixes:
None filed. Follow-up to #7954.
Checklist
CHANGELOG.mdupdated - the order of entries should be[CHANGE],[FEATURE],[ENHANCEMENT],[BUGFIX]docs/configuration/v1-guarantees.mdupdated if this PR introduces experimental flags