Skip to content

Commit 2a79c25

Browse files
sandy2008claude
andcommitted
Merge remote-tracking branch 'upstream/master' into fix-promql-compat-error-comparator
Resolve conflict in integration/query_fuzz_test.go: keep upstream's new TestLazyMatchersFuzz, newFuzzRand helper, and TestExpandedPostingsCacheFuzz repairs, and re-apply this branch's sameErrorClass comparator at all four error-comparison sites (including the new TestLazyMatchersFuzz site, which is susceptible to the same duplicate-series flake). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Sandy Chen <Yuxuan.Chen@morganstanley.com>
2 parents d08ef43 + aa717c3 commit 2a79c25

45 files changed

Lines changed: 3164 additions & 1398 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
* [ENHANCEMENT] Distributor: Add HMAC-SHA256 stream authentication for `PushStream` via `-distributor.sign-write-requests-keys`. #7475
2828
* [ENHANCEMENT] Instrument Ingester CPU profile with source for read APIs. #7494
2929
* [ENHANCEMENT] Ingester: Convert expanded postings cache from FIFO to LRU eviction to retain frequently-queried entries under memory pressure. #7510
30+
* [ENHANCEMENT] Querier: Detach series label and chunk data from gRPC unmarshal buffers in store-gateway streaming path, allowing the Go GC to reclaim receive buffers. #7519
31+
* [ENHANCEMENT] Distributor: Added `cortex_distributor_received_histogram_buckets` metric to track number of buckets in received native histogram samples before validation, per user. #7569
32+
* [ENHANCEMENT] Distributor: Add `WrappedHistogram` with configurable size limit (`-validation.max-native-histogram-size-bytes`) to cap native histogram protobuf size before unmarshalling. #7570
33+
* [ENHANCEMENT] Ingester: Add lazy regex evaluation on head postings cache miss. Defers expensive regex matchers on high-cardinality labels to per-series filtering when a selective equality matcher already narrows the result set. Configured via `-blocks-storage.expanded_postings_cache.head.lazy-matcher-max-cardinality` (disabled by default). #7553
3034
* [BUGFIX] Querier: Fix queryWithRetry and labelsWithRetry returning (nil, nil) on cancelled context by propagating ctx.Err(). #7370
3135
* [BUGFIX] Metrics Helper: Fix non-deterministic bucket order in merged histograms by sorting buckets after map iteration, matching Prometheus client library behavior. #7380
3236
* [BUGFIX] Distributor: Return HTTP 401 Unauthorized when tenant ID resolution fails in the Prometheus Remote Write 2.0 path. #7389
@@ -38,7 +42,12 @@
3842
* [BUGFIX] Compactor: Fix stale `cortex_bucket_index_last_successful_update_timestamp_seconds` metric not being cleaned up when tenant ownership changes due to ring rebalancing. This caused false alarms on bucket index update rate when a tenant moved between compactors. #7485
3943
* [BUGFIX] Security: Fix stored XSS vulnerability in Alertmanager and Store Gateway status pages by replacing `text/template` with `html/template`. #7512
4044
* [BUGFIX] Security: Limit decompressed gzip output in `ParseProtoReader` and OTLP ingestion path. The decompressed body is now capped by `-distributor.otlp-max-recv-msg-size`. #7515
45+
* [BUGFIX] Ingester: Close TSDB when compaction fails during `createTSDB`, preventing resource leaks (file descriptors, mmap handles) that could lead to ingester instability. #7560
4146
* [BUGFIX] Tenant Federation: Fix regex resolver clearing known users list when user scan fails. #7534
47+
* [BUGFIX] Ingester: Release the TSDB appender on every early-return path in `Push` (e.g. out-of-order label set) by deferring `Rollback`. Previously such requests leaked TSDB head series references, mmap'd chunks and pending state per request, causing the `cortex_ingester_tsdb_head_active_appenders` gauge to grow unbounded. #7528
48+
* [BUGFIX] Ring: Fix ring token conflict resolution only applied to updated instance and make constantly token conflict check during instance observe period.
49+
* [BUGFIX] Distributor: Fix a panic (`slice bounds out of range`) in the stream push path when the context deadline expires while the worker goroutine is still marshalling a `WriteRequest`. #7541
50+
* [BUGFIX] Query Frontend: Fix native histogram responses not being handled correctly in `minTime()` sort ordering for split_by_interval merge. #7555
4251

4352
## 1.21.0 2026-04-24
4453

MAINTAINERS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@
1616
|-----------------|----------------------------|-----------------|---------------------|
1717
| Anand Rajagopal | anand.rajagopal@icloud.com | @rajagopalanand | Amazon Web Services |
1818
| Daniel Sabsay | danielsabsay.sofware@gmail.com | @dsabsay | Adobe |
19+
| Yuxuan Chen | sandy19890604@gmail.com | @sandy2008 | Morgan Stanley |
20+

docs/blocks-storage/querier.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1970,6 +1970,25 @@ blocks_storage:
19701970
# CLI flag: -blocks-storage.expanded_postings_cache.block.fetch-timeout
19711971
[fetch_timeout: <duration> | default = 0s]
19721972

1973+
# [EXPERIMENTAL] Maximum label cardinality for deferring regex matchers on
1974+
# the head block. When a regex matcher targets a label with more unique
1975+
# values than this threshold, it is applied lazily during iteration
1976+
# instead of postings lookup. 0 disables.
1977+
# CLI flag: -blocks-storage.expanded_postings_cache.head.lazy-matcher-max-cardinality
1978+
[lazy_matcher_max_cardinality: <int> | default = 0]
1979+
1980+
# [EXPERIMENTAL] Cardinality:postings ratio above which a simple regex
1981+
# (prefix-only, single contains) is deferred to lazy iteration. Lower =
1982+
# more aggressive deferral. Calibrated empirically; defaults to 6.
1983+
# CLI flag: -blocks-storage.expanded_postings_cache.head.lazy-matcher-simple-cost-ratio
1984+
[lazy_matcher_simple_cost_ratio: <int> | default = 6]
1985+
1986+
# [EXPERIMENTAL] Cardinality:postings ratio above which a complex regex
1987+
# (multi-substring, capture groups, character classes) is deferred. Lower
1988+
# = more aggressive deferral. Calibrated empirically; defaults to 2.
1989+
# CLI flag: -blocks-storage.expanded_postings_cache.head.lazy-matcher-complex-cost-ratio
1990+
[lazy_matcher_complex_cost_ratio: <int> | default = 2]
1991+
19731992
users_scanner:
19741993
# Strategy to use to scan users. Supported values are: list, user_index.
19751994
# CLI flag: -blocks-storage.users-scanner.strategy

docs/blocks-storage/store-gateway.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2028,6 +2028,25 @@ blocks_storage:
20282028
# CLI flag: -blocks-storage.expanded_postings_cache.block.fetch-timeout
20292029
[fetch_timeout: <duration> | default = 0s]
20302030

2031+
# [EXPERIMENTAL] Maximum label cardinality for deferring regex matchers on
2032+
# the head block. When a regex matcher targets a label with more unique
2033+
# values than this threshold, it is applied lazily during iteration
2034+
# instead of postings lookup. 0 disables.
2035+
# CLI flag: -blocks-storage.expanded_postings_cache.head.lazy-matcher-max-cardinality
2036+
[lazy_matcher_max_cardinality: <int> | default = 0]
2037+
2038+
# [EXPERIMENTAL] Cardinality:postings ratio above which a simple regex
2039+
# (prefix-only, single contains) is deferred to lazy iteration. Lower =
2040+
# more aggressive deferral. Calibrated empirically; defaults to 6.
2041+
# CLI flag: -blocks-storage.expanded_postings_cache.head.lazy-matcher-simple-cost-ratio
2042+
[lazy_matcher_simple_cost_ratio: <int> | default = 6]
2043+
2044+
# [EXPERIMENTAL] Cardinality:postings ratio above which a complex regex
2045+
# (multi-substring, capture groups, character classes) is deferred. Lower
2046+
# = more aggressive deferral. Calibrated empirically; defaults to 2.
2047+
# CLI flag: -blocks-storage.expanded_postings_cache.head.lazy-matcher-complex-cost-ratio
2048+
[lazy_matcher_complex_cost_ratio: <int> | default = 2]
2049+
20312050
users_scanner:
20322051
# Strategy to use to scan users. Supported values are: list, user_index.
20332052
# CLI flag: -blocks-storage.users-scanner.strategy

docs/configuration/config-file-reference.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2650,6 +2650,25 @@ tsdb:
26502650
# CLI flag: -blocks-storage.expanded_postings_cache.block.fetch-timeout
26512651
[fetch_timeout: <duration> | default = 0s]
26522652

2653+
# [EXPERIMENTAL] Maximum label cardinality for deferring regex matchers on
2654+
# the head block. When a regex matcher targets a label with more unique
2655+
# values than this threshold, it is applied lazily during iteration instead
2656+
# of postings lookup. 0 disables.
2657+
# CLI flag: -blocks-storage.expanded_postings_cache.head.lazy-matcher-max-cardinality
2658+
[lazy_matcher_max_cardinality: <int> | default = 0]
2659+
2660+
# [EXPERIMENTAL] Cardinality:postings ratio above which a simple regex
2661+
# (prefix-only, single contains) is deferred to lazy iteration. Lower = more
2662+
# aggressive deferral. Calibrated empirically; defaults to 6.
2663+
# CLI flag: -blocks-storage.expanded_postings_cache.head.lazy-matcher-simple-cost-ratio
2664+
[lazy_matcher_simple_cost_ratio: <int> | default = 6]
2665+
2666+
# [EXPERIMENTAL] Cardinality:postings ratio above which a complex regex
2667+
# (multi-substring, capture groups, character classes) is deferred. Lower =
2668+
# more aggressive deferral. Calibrated empirically; defaults to 2.
2669+
# CLI flag: -blocks-storage.expanded_postings_cache.head.lazy-matcher-complex-cost-ratio
2670+
[lazy_matcher_complex_cost_ratio: <int> | default = 2]
2671+
26532672
users_scanner:
26542673
# Strategy to use to scan users. Supported values are: list, user_index.
26552674
# CLI flag: -blocks-storage.users-scanner.strategy

docs/configuration/v1-guarantees.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,7 @@ Currently experimental features are:
133133
- Ingester: Active Series Tracker
134134
- Per-tenant `active_series_trackers` configuration in runtime config overrides
135135
- Counts active series matching PromQL label matchers and exposes `cortex_ingester_active_series_per_tracker` metric
136+
- Ingester: Lazy regex evaluation on head postings cache miss
137+
- `-blocks-storage.expanded_postings_cache.head.lazy-matcher-max-cardinality` (int) CLI flag
138+
- `-blocks-storage.expanded_postings_cache.head.lazy-matcher-simple-cost-ratio` (int) CLI flag
139+
- `-blocks-storage.expanded_postings_cache.head.lazy-matcher-complex-cost-ratio` (int) CLI flag

integration/parquet_querier_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ package integration
55
import (
66
"context"
77
"fmt"
8-
"math/rand"
98
"path/filepath"
109
"slices"
1110
"strconv"
@@ -89,7 +88,7 @@ func TestParquetFuzz(t *testing.T) {
8988
require.NoError(t, writeFileToSharedDir(s, "alertmanager_configs", []byte{}))
9089

9190
ctx := context.Background()
92-
rnd := rand.New(rand.NewSource(time.Now().Unix()))
91+
rnd := newFuzzRand(t)
9392
dir := filepath.Join(s.SharedDir(), "data")
9493
numSeries := 10
9594
numSamples := 60
@@ -172,6 +171,7 @@ func TestParquetFuzz(t *testing.T) {
172171
opts := []promqlsmith.Option{
173172
// @ modifier and offset disabled: known bug in Prometheus (e.g. predict_linear with @/offset can panic).
174173
promqlsmith.WithEnabledFunctions(enabledFunctions),
174+
promqlsmith.WithEnabledAggrs(enabledAggrs),
175175
}
176176
ps := promqlsmith.New(rnd, lbls, opts...)
177177

@@ -240,7 +240,7 @@ func TestParquetProjectionPushdownFuzz(t *testing.T) {
240240
require.NoError(t, writeFileToSharedDir(s, "alertmanager_configs", []byte{}))
241241

242242
ctx := context.Background()
243-
rnd := rand.New(rand.NewSource(time.Now().Unix()))
243+
rnd := newFuzzRand(t)
244244
dir := filepath.Join(s.SharedDir(), "data")
245245
numSeries := 20
246246
numSamples := 100

0 commit comments

Comments
 (0)