From 4bb7e42d67fcb6054dbf83056c545c04d18fb4e5 Mon Sep 17 00:00:00 2001 From: Saswata Mukherjee Date: Wed, 18 Oct 2023 18:06:32 +0530 Subject: [PATCH] Revert "Fix matchersToPostingGroups vals variable shadow bug (#6817)" This reverts commit 4ed9bb0317122e9dc31c2548581972c27d4e2e33. --- CHANGELOG.md | 1 - pkg/store/bucket.go | 3 +-- pkg/store/bucket_test.go | 23 ----------------------- 3 files changed, 1 insertion(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 477361b370b..8f62eda94a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,7 +25,6 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re - [#6615](https://github.com/thanos-io/thanos/pull/6615) [#6805](https://github.com/thanos-io/thanos/pull/6805): Build with Go 1.21 and bump golang.org/x/net to v0.17 for addressing [CVE](https://groups.google.com/g/golang-announce/c/iNNxDTCjZvo) - [#6802](https://github.com/thanos-io/thanos/pull/6802) Receive: head series limiter should not run if no head series limit is set. - [#6816](https://github.com/thanos-io/thanos/pull/6816) Store: fix prometheus store label values matches for external labels -- [#6817](https://github.com/thanos-io/thanos/pull/6817) Store Gateway: fix `matchersToPostingGroups` label values variable got shadowed bug. ### Added diff --git a/pkg/store/bucket.go b/pkg/store/bucket.go index c491c8f9cf6..8b12e13e4f0 100644 --- a/pkg/store/bucket.go +++ b/pkg/store/bucket.go @@ -2503,9 +2503,8 @@ func matchersToPostingGroups(ctx context.Context, lvalsFn func(name string) ([]s } // Cache label values because label name is the same. if !valuesCached && vals != nil { - lvals := vals lvalsFunc = func(_ string) ([]string, error) { - return lvals, nil + return vals, nil } valuesCached = true } diff --git a/pkg/store/bucket_test.go b/pkg/store/bucket_test.go index 55e4d830f83..bd73e5d08d0 100644 --- a/pkg/store/bucket_test.go +++ b/pkg/store/bucket_test.go @@ -3076,29 +3076,6 @@ func TestMatchersToPostingGroup(t *testing.T) { }, }, }, - { - name: "Reproduce values shadow bug", - matchers: []*labels.Matcher{ - labels.MustNewMatcher(labels.MatchRegexp, "name", "test.*"), - labels.MustNewMatcher(labels.MatchNotRegexp, "name", "testfoo"), - labels.MustNewMatcher(labels.MatchNotEqual, "name", ""), - }, - labelValues: map[string][]string{ - "name": {"testbar", "testfoo"}, - }, - expected: []*postingGroup{ - { - name: "name", - addAll: false, - addKeys: []string{"testbar"}, - matchers: []*labels.Matcher{ - labels.MustNewMatcher(labels.MatchNotEqual, "name", ""), - labels.MustNewMatcher(labels.MatchRegexp, "name", "test.*"), - labels.MustNewMatcher(labels.MatchNotRegexp, "name", "testfoo"), - }, - }, - }, - }, } { t.Run(tc.name, func(t *testing.T) { actual, err := matchersToPostingGroups(ctx, func(name string) ([]string, error) {