diff --git a/go.mod b/go.mod index a3fe4fdf8bb..b15d4dc8264 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/armon/go-metrics v0.4.1 github.com/aws/aws-sdk-go v1.55.5 github.com/bradfitz/gomemcache v0.0.0-20230905024940-24af94b03874 - github.com/cortexproject/promqlsmith v0.0.0-20250128002239-eaf3e57157fc + github.com/cortexproject/promqlsmith v0.0.0-20250203072244-cbb5738d00ca github.com/dustin/go-humanize v1.0.1 github.com/efficientgo/core v1.0.0-rc.3 github.com/facette/natsort v0.0.0-20181210072756-2cd4dd1e2dcb @@ -52,7 +52,7 @@ require ( github.com/stretchr/testify v1.10.0 github.com/thanos-io/objstore v0.0.0-20241111205755-d1dd89d41f97 github.com/thanos-io/promql-engine v0.0.0-20250110162513-14f995518af3 - github.com/thanos-io/thanos v0.37.3-0.20250115144759-236777732278 + github.com/thanos-io/thanos v0.37.3-0.20250203070737-57efc2aacd6f github.com/uber/jaeger-client-go v2.30.0+incompatible github.com/weaveworks/common v0.0.0-20230728070032-dd9e68f319d5 go.etcd.io/etcd/api/v3 v3.5.17 diff --git a/go.sum b/go.sum index 549b4e367c1..b91e0501f9a 100644 --- a/go.sum +++ b/go.sum @@ -934,8 +934,8 @@ github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3Ee github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= -github.com/cortexproject/promqlsmith v0.0.0-20250128002239-eaf3e57157fc h1:paM+YXwcIaz108+bFrm5aCepwVSxBfq48gb3Zc1z/nQ= -github.com/cortexproject/promqlsmith v0.0.0-20250128002239-eaf3e57157fc/go.mod h1:xbYQa0KX6Eh6YWbTBfZ9kK3N4hRxX+ZPIfVIY2U/y00= +github.com/cortexproject/promqlsmith v0.0.0-20250203072244-cbb5738d00ca h1:TvKuPFRUQ39O07xv3b+TO6GBRhchYKyBCCXrlmmDE3Y= +github.com/cortexproject/promqlsmith v0.0.0-20250203072244-cbb5738d00ca/go.mod h1:xbYQa0KX6Eh6YWbTBfZ9kK3N4hRxX+ZPIfVIY2U/y00= github.com/cortexproject/weaveworks-common v0.0.0-20241129212437-96019edf21f1 h1:UoSixdl0sBUhfEOMpIGxFnJjp3/y/+nkw6Du7su05FE= github.com/cortexproject/weaveworks-common v0.0.0-20241129212437-96019edf21f1/go.mod h1:7cl8fS/nivXe2DmBUUmr/3UGTJG2jVU2NRaIayR2Zjs= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= @@ -1657,8 +1657,8 @@ github.com/thanos-io/objstore v0.0.0-20241111205755-d1dd89d41f97 h1:VjG0mwhN1Dkn github.com/thanos-io/objstore v0.0.0-20241111205755-d1dd89d41f97/go.mod h1:vyzFrBXgP+fGNG2FopEGWOO/zrIuoy7zt3LpLeezRsw= github.com/thanos-io/promql-engine v0.0.0-20250110162513-14f995518af3 h1:feQKBuPhRE/+xd4Ru6Jv48EzVatpXg2mnpl0x0f5OWY= github.com/thanos-io/promql-engine v0.0.0-20250110162513-14f995518af3/go.mod h1:wx0JlRZtsB2S10JYUgeg5GqLfMxw31SzArP+28yyE00= -github.com/thanos-io/thanos v0.37.3-0.20250115144759-236777732278 h1:HkZohVruRD0ENAXZIl2qDcpblbMok++jb3zHvjUeQfg= -github.com/thanos-io/thanos v0.37.3-0.20250115144759-236777732278/go.mod h1:DvlfyJhdYeufGbw3z6VQuDpGh2Q46/XvalnmEtQOf/0= +github.com/thanos-io/thanos v0.37.3-0.20250203070737-57efc2aacd6f h1:Q8lYAyPHlQsMCwBu1UVr15dXb4CdsqKOf0Hx/tWx90g= +github.com/thanos-io/thanos v0.37.3-0.20250203070737-57efc2aacd6f/go.mod h1:Y86Y7QT3nlYNC1bGCPYBHDn2ecDzblYBJRhs41u8qcY= github.com/tjhop/slog-gokit v0.1.2 h1:pmQI4SvU9h4gA0vIQsdhJQSqQg4mOmsPykG2/PM3j1I= github.com/tjhop/slog-gokit v0.1.2/go.mod h1:8fhlcp8C8ELbg3GCyKv06tgt4B5sDq2P1r2DQAu1HuM= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= diff --git a/vendor/github.com/cortexproject/promqlsmith/walk.go b/vendor/github.com/cortexproject/promqlsmith/walk.go index 06d55067b14..ae83d19db80 100644 --- a/vendor/github.com/cortexproject/promqlsmith/walk.go +++ b/vendor/github.com/cortexproject/promqlsmith/walk.go @@ -462,6 +462,11 @@ func (s *PromQLSmith) walkLabelMatchers() []*labels.Matcher { }) valF := func(v string) string { + // If a label value contains + such as +Inf it will cause parse error for regex. + // Always hardcode to .+ for simplicity. + if strings.Contains(v, "+") { + return ".+" + } val := s.rnd.Float64() switch { case val > 0.95: @@ -489,7 +494,11 @@ func (s *PromQLSmith) walkLabelMatchers() []*labels.Matcher { matchType := labels.MatchType(res) switch matchType { case labels.MatchEqual: - matcher = labels.MustNewMatcher(labels.MatchEqual, lbls[orders[i]].Name, lbls[orders[i]].Value) + val := lbls[orders[i]].Value + if s.rnd.Float64() > 0.9 { + val = "" + } + matcher = labels.MustNewMatcher(labels.MatchEqual, lbls[orders[i]].Name, val) case labels.MatchNotEqual: val := lbls[orders[i]].Value if s.rnd.Float64() > 0.9 { diff --git a/vendor/github.com/thanos-io/thanos/pkg/store/bucket.go b/vendor/github.com/thanos-io/thanos/pkg/store/bucket.go index 6e5a656e629..7e23a388d12 100644 --- a/vendor/github.com/thanos-io/thanos/pkg/store/bucket.go +++ b/vendor/github.com/thanos-io/thanos/pkg/store/bucket.go @@ -585,7 +585,7 @@ func WithLazyExpandedPostings(enabled bool) BucketStoreOption { } } -// WithPostingGroupMaxKeySeriesRatio configures a threshold to mark a posting group as lazy if it has more add keys. +// WithPostingGroupMaxKeySeriesRatio configures a threshold to mark a posting group as lazy if it has more add keys or remove keys. func WithPostingGroupMaxKeySeriesRatio(postingGroupMaxKeySeriesRatio float64) BucketStoreOption { return func(s *BucketStore) { s.postingGroupMaxKeySeriesRatio = postingGroupMaxKeySeriesRatio @@ -1076,7 +1076,7 @@ type blockSeriesClient struct { lazyExpandedPostingEnabled bool seriesMatchRatio float64 - // Mark posting group as lazy if it adds too many keys. 0 to disable. + // Mark posting group as lazy if it adds or removes too many keys. 0 to disable. postingGroupMaxKeySeriesRatio float64 lazyExpandedPostingsCount prometheus.Counter lazyExpandedPostingGroupByReason *prometheus.CounterVec @@ -2978,6 +2978,12 @@ func toPostingGroup(ctx context.Context, lvalsFn func(name string) ([]string, er return nil, nil, err } + // If the matcher is ="" or =~"", it is the same as removing all values for the label. + // We can skip calling `Matches` here. + if m.Value == "" && (m.Type == labels.MatchEqual || m.Type == labels.MatchRegexp) { + return newPostingGroup(true, m.Name, nil, vals), vals, nil + } + for i, val := range vals { if (i+1)%checkContextEveryNIterations == 0 && ctx.Err() != nil { return nil, nil, ctx.Err() @@ -3006,6 +3012,12 @@ func toPostingGroup(ctx context.Context, lvalsFn func(name string) ([]string, er return nil, nil, err } + // If the matcher is !="" or !~"", it is the same as adding all values for the label. + // We can skip calling `Matches` here. + if m.Value == "" && (m.Type == labels.MatchNotEqual || m.Type == labels.MatchNotRegexp) { + return newPostingGroup(false, m.Name, vals, nil), vals, nil + } + var toAdd []string for i, val := range vals { if (i+1)%checkContextEveryNIterations == 0 && ctx.Err() != nil { diff --git a/vendor/github.com/thanos-io/thanos/pkg/store/lazy_postings.go b/vendor/github.com/thanos-io/thanos/pkg/store/lazy_postings.go index 325e92e9040..2d6eea6062a 100644 --- a/vendor/github.com/thanos-io/thanos/pkg/store/lazy_postings.go +++ b/vendor/github.com/thanos-io/thanos/pkg/store/lazy_postings.go @@ -166,6 +166,13 @@ func optimizePostingsFetchByDownloadedBytes( if seriesMatched <= 0 { break } + // Only mark posting group as lazy due to too many keys when those keys are known to be existent. + if postingGroupMaxKeySeriesRatio > 0 && maxSeriesMatched > 0 && + float64(pg.existentKeys)/float64(maxSeriesMatched) > postingGroupMaxKeySeriesRatio { + markPostingGroupLazy(pg, "keys_limit", lazyExpandedPostingSizeBytes, lazyExpandedPostingGroupsByReason) + i++ + continue + } if pg.addAll { // For posting group that has negative matchers, we assume we can underfetch // min(pg.cardinality, current_series_matched) * match ratio series. @@ -177,13 +184,6 @@ func optimizePostingsFetchByDownloadedBytes( seriesMatched -= underfetchedSeries underfetchedSeriesSize = underfetchedSeries * seriesMaxSize } else { - // Only mark posting group as lazy due to too many keys when those keys are known to be existent. - if postingGroupMaxKeySeriesRatio > 0 && maxSeriesMatched > 0 && - float64(pg.existentKeys)/float64(maxSeriesMatched) > postingGroupMaxKeySeriesRatio { - markPostingGroupLazy(pg, "keys_limit", lazyExpandedPostingSizeBytes, lazyExpandedPostingGroupsByReason) - i++ - continue - } underfetchedSeriesSize = seriesMaxSize * int64(math.Ceil(float64(seriesMatched)*(1-seriesMatchRatio))) seriesMatched = int64(math.Ceil(float64(seriesMatched) * seriesMatchRatio)) } diff --git a/vendor/modules.txt b/vendor/modules.txt index aa96a865c9e..e5ece82bb45 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -303,7 +303,7 @@ github.com/coreos/go-semver/semver ## explicit; go 1.12 github.com/coreos/go-systemd/v22/activation github.com/coreos/go-systemd/v22/journal -# github.com/cortexproject/promqlsmith v0.0.0-20250128002239-eaf3e57157fc +# github.com/cortexproject/promqlsmith v0.0.0-20250203072244-cbb5738d00ca ## explicit; go 1.22.0 github.com/cortexproject/promqlsmith # github.com/cristalhq/hedgedhttp v0.9.1 @@ -988,7 +988,7 @@ github.com/thanos-io/promql-engine/query github.com/thanos-io/promql-engine/ringbuffer github.com/thanos-io/promql-engine/storage github.com/thanos-io/promql-engine/storage/prometheus -# github.com/thanos-io/thanos v0.37.3-0.20250115144759-236777732278 +# github.com/thanos-io/thanos v0.37.3-0.20250203070737-57efc2aacd6f ## explicit; go 1.23.0 github.com/thanos-io/thanos/pkg/api/query/querypb github.com/thanos-io/thanos/pkg/block