Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
a3b283a
ring: simplify zonal ownership and report duplicate tokens
alanprot Nov 23, 2026
91f3c91
ingester: keep only each tenant's ownership share
alanprot Nov 23, 2026
3c1ec99
ingester: recompute ownership shares computed from a changing ring
alanprot Nov 23, 2026
294ea0d
ingester: simplify the ownership refresher
alanprot Nov 23, 2026
573f1d6
ingester: hash ownership fingerprints with xxhash
alanprot Nov 23, 2026
90bef55
ingester: refresh ownership shares in their own service
alanprot Nov 23, 2026
b7aa09b
ring: count a token shared across zones where Get routes it
alanprot Nov 24, 2026
86a4e5a
ingester: compute ownership shares from a ring no heartbeat changes
alanprot Nov 24, 2026
48661dd
ingester: compare the ring with the kept copy instead of hashing it
alanprot Nov 24, 2026
0f13b52
ingester: drop the ownership refresh wrapper without a context
alanprot Nov 24, 2026
209101d
ingester: correct the ownership comments and CHANGELOG entry
alanprot Nov 24, 2026
3f476fb
CHANGELOG: shorten the ring ownership entry
alanprot Nov 24, 2026
1ffc17a
ingester: tell this ingester apart in the ownership fingerprint
alanprot Nov 24, 2026
94606e0
ingester: test the ownership refresh the ingester runs
alanprot Nov 24, 2026
b96f2ce
CHANGELOG: fold the ring ownership entries into one
alanprot Nov 24, 2026
3b0543f
ingester: rename the ownership share's unsure flag to duplicates
alanprot Nov 24, 2026
6cbe13f
CHANGELOG: shorten the ring ownership entry
alanprot Nov 24, 2026
0269349
CHANGELOG: note that ring ownership shares ignore extend-writes
alanprot Nov 24, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* [FEATURE] Storage: Add support for Alibaba Cloud OSS as a backend for blocks, ruler, and alertmanager storage. Configured via `-<prefix>.oss.*` flags with `backend: oss`. #7907
* [ENHANCEMENT] Compactor: Add `-compactor.block-ranges-compaction-delay` to configure the compaction group graceful period per `-compactor.block-ranges` entry, matched by position. A larger block range can now be held back until its sub-ranges have settled, instead of every range sharing one period derived from `-compactor.cleanup-interval`. Leaving it empty, and any range without an entry, keeps the current behaviour of twice `-compactor.cleanup-interval`. The delay is a lower bound: groups only become eligible on a compaction run, so the effective wait can be up to `-compactor.compaction-interval` longer. Only used by the partitioning compaction strategy. #7916
* [ENHANCEMENT] Ring: Add the `cortex_ring_member_zonal_ownership_percent{name, member, zone}` metric, reporting the fraction of its own zone's token space owned by each ring member. With zone-aware replication a write is routed within a single zone, so the existing `cortex_ring_member_ownership_percent`, which is computed over the merged token list of all zones, does not reflect the hash range a member actually serves. Reported when ring detailed metrics and zone awareness are both enabled. #7910
* [ENHANCEMENT] Ingester: Add experimental `-ingester.use-ring-ownership-for-limits`. With zone-aware replication, global series and metadata limits are converted to per-ingester limits using the share of each tenant's hash space (or shuffle shard) the ingester owns within its zone, instead of assuming every ingester owns an equal share. Requires zone-aware replication; while the number of zones in the ring differs from the replication factor, the equal-share conversion is used. On an unevenly balanced ring the equal-share assumption throttles tenants on the ingesters with the largest share well before they reach their global limit. The ring is read from the ingester's own heartbeats, so no KV store traffic is added. The share in use is exposed as `cortex_ingester_ring_ownership_share{user}`. #7954
* [ENHANCEMENT] Ingester: Add experimental `-ingester.use-ring-ownership-for-limits` (requires zone-aware replication). It converts global series and metadata limits to per-ingester limits using the ingester's actual share of each tenant's hash space within its zone, instead of an equal share, which throttles tenants early on an unbalanced ring. Shares ignore `-distributor.extend-writes`, so a tenant can be throttled early while an instance is JOINING, LEAVING or PENDING. Exposes `cortex_ingester_ring_ownership_share{user}` and `cortex_ingester_ring_ownership_computations_total`. #7954 #7961
* [ENHANCEMENT] Distributor: Support partial write for Prometheus Remote Write 2.0 requests. Invalid series are now skipped and reported together in the `400` response instead of rejecting the whole batch, the valid ones are written, and the `X-Prometheus-Remote-Write-*-Written` response headers are set even when a `400` is returned. #7761
* [ENHANCEMENT] Ruler: Add rule information to query parameters sent to the Query Frontend when `-ruler.frontend-address` is configured, so the Query Frontend query stats logs (`-frontend.enabled-ruler-query-stats`) can identify the evaluated rule. In this mode, the Ruler query stats log (`-ruler.query-stats-enabled`) omits the fetched statistics fields, which are always zero. #6539
* [ENHANCEMENT] gRPC: When `-auth.enabled=true`, a gRPC request without the `X-Scope-OrgID` metadata is now rejected with the `UNAUTHENTICATED` status code instead of `UNKNOWN`. #7873
Expand Down
2 changes: 1 addition & 1 deletion integration/ingester_ownership_limits_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ func ownershipLimitsShares(t *testing.T, instances []struct {
}

shares := map[string]float64{}
for id, share := range scoped.(ring.ZonalOwnershipRing).ZonalOwnership(ring.Write) {
for id, share := range scoped.(ring.ZonalOwnershipRing).ZonalOwnership() {
if share > 0 {
shares[id] = share
}
Expand Down
1 change: 0 additions & 1 deletion pkg/cortex/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,6 @@ func (t *Cortex) initIngesterService() (serv services.Service, err error) {
t.Cfg.Ingester.LifecyclerConfig.ListenPort = t.Cfg.Server.GRPCListenPort
t.Cfg.Ingester.DistributorShardingStrategy = t.Cfg.Distributor.ShardingStrategy
t.Cfg.Ingester.DistributorShardByAllLabels = t.Cfg.Distributor.ShardByAllLabels
t.Cfg.Ingester.DistributorExtendWrites = t.Cfg.Distributor.ExtendWrites
t.Cfg.Ingester.InstanceLimitsFn = ingesterInstanceLimits(t.RuntimeConfig)
t.tsdbIngesterConfig()

Expand Down
27 changes: 12 additions & 15 deletions pkg/ingester/ingester.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ type Config struct {
// to accurately apply global limits.
DistributorShardingStrategy string `yaml:"-"`
DistributorShardByAllLabels bool `yaml:"-"`
DistributorExtendWrites bool `yaml:"-"`

UseRingOwnershipForLimits bool `yaml:"use_ring_ownership_for_limits"`

Expand Down Expand Up @@ -898,7 +897,7 @@ func New(cfg Config, limits *validation.Overrides, registerer prometheus.Registe
}, i.getOldestUnshippedBlockMetric)
}

ownershipDelegate := &ringOwnershipDelegate{}
ownershipDelegate := &ringOwnershipDelegate{enabled: cfg.UseRingOwnershipForLimits}
i.lifecycler, err = ring.NewLifecyclerWithDelegate(cfg.LifecyclerConfig, i, "ingester", RingKey, false, cfg.BlocksStorageConfig.TSDB.FlushBlocksOnShutdown, logger, prometheus.WrapRegistererWithPrefix("cortex_", registerer), ownershipDelegate)
if err != nil {
return nil, err
Expand All @@ -918,12 +917,13 @@ func New(cfg Config, limits *validation.Overrides, registerer prometheus.Registe
)

if cfg.UseRingOwnershipForLimits {
ownershipRing, err := ring.NewDescFedRing(cfg.LifecyclerConfig.RingConfig, "ingester-ownership", RingKey, i.lifecycler.KVStore, logger)
if err != nil {
newRing := func() (*ring.Ring, error) {
return newOwnershipRing(cfg.LifecyclerConfig.RingConfig, i.lifecycler.KVStore, logger)
}
if _, err := newRing(); err != nil {
return nil, errors.Wrap(err, "failed to create the ring for ownership-based limits")
}
ownershipDelegate.ring.Store(ownershipRing)
i.ownershipRefresher = newOwnershipRefresher(ownershipRing, i.lifecycler.ID, cfg.DistributorExtendWrites, i.limiter.shuffleShardingEnabled, limits, registerer)
i.ownershipRefresher = newOwnershipRefresher(ownershipDelegate.latest, newRing, i.lifecycler.ID, i.limiter.shuffleShardingEnabled, limits, registerer)
i.limiter.ownership = i.ownershipRefresher.ownership
}

Expand Down Expand Up @@ -1041,6 +1041,12 @@ func (i *Ingester) starting(ctx context.Context) error {
compactionService := services.NewBasicService(nil, i.compactionLoop, nil)
servs = append(servs, compactionService)

if i.ownershipRefresher != nil {
// Its own service: after a ring change a refresh can take seconds, which
// must not delay updateLoop and the ingestion rate it ticks.
servs = append(servs, services.NewTimerService(ownershipRefreshPeriod, nil, i.refreshOwnership, nil))
}

if i.cfg.BlocksStorageConfig.TSDB.IsBlocksShippingEnabled() {
shippingService := services.NewBasicService(nil, i.shipBlocksLoop, nil)
servs = append(servs, shippingService)
Expand Down Expand Up @@ -1143,13 +1149,6 @@ func (i *Ingester) updateLoop(ctx context.Context) error {
labelSetMetricsTicker := time.NewTicker(labelSetMetricsTickInterval)
defer labelSetMetricsTicker.Stop()

var ownershipTickerChan <-chan time.Time
if i.ownershipRefresher != nil {
t := time.NewTicker(ownershipRefreshPeriod)
ownershipTickerChan = t.C
defer t.Stop()
}

for {
select {
case <-metadataPurgeTicker.C:
Expand Down Expand Up @@ -1177,8 +1176,6 @@ func (i *Ingester) updateLoop(ctx context.Context) error {
i.updateUserTSDBConfigs()
case <-labelSetMetricsTicker.C:
i.updateLabelSetMetrics()
case <-ownershipTickerChan:
i.ownershipRefresher.refresh(i.getTSDBUsers())
case <-ctx.Done():
return nil
case err := <-i.subservicesWatcher.Chan():
Expand Down
Loading