Skip to content

Commit

Permalink
Remove optimizations for label=~".*" and label!~".*". (#2475)
Browse files Browse the repository at this point in the history
* Remove optimizations for label=~".*" and label!~".*".

They are not correct.

Signed-off-by: Peter Štibraný <peter.stibrany@grafana.com>

* CHANGELOG.md

Signed-off-by: Peter Štibraný <peter.stibrany@grafana.com>
  • Loading branch information
pstibrany committed Apr 20, 2020
1 parent 853175a commit 4d41d36
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -20,6 +20,7 @@ We use *breaking* word for marking changes that are not backward compatible (rel

### Changed
- [#2450](https://github.com/thanos-io/thanos/pull/2450) Store: regex-set optimization for `label=~"a|b|c"` matchers.
- [#2475](https://github.com/thanos-io/thanos/pull/2475) Store: remove incorrect optimizations for queries with `=~".*"` and `!=~".*"` matchers.

## [v0.12.0](https://github.com/thanos-io/thanos/releases/tag/v0.12.0) - 2020.04.15

Expand Down
15 changes: 0 additions & 15 deletions pkg/store/bucket.go
Expand Up @@ -1485,23 +1485,8 @@ func checkNilPosting(l labels.Label, p index.Postings) index.Postings {
return p
}

var (
allPostingsGroup = newPostingGroup(true, nil, nil)
emptyPostingsGroup = newPostingGroup(false, nil, nil)
)

// NOTE: Derived from tsdb.postingsForMatcher. index.Merge is equivalent to map duplication.
func toPostingGroup(lvalsFn func(name string) ([]string, error), m *labels.Matcher) (*postingGroup, error) {
// This matches any label value, and also series that don't have this label at all.
if m.Type == labels.MatchRegexp && (m.Value == ".*" || m.Value == "^.*$") {
return allPostingsGroup, nil
}

// NOT matching any value = match nothing. We can shortcut this easily.
if m.Type == labels.MatchNotRegexp && (m.Value == ".*" || m.Value == "^.*$") {
return emptyPostingsGroup, nil
}

if m.Type == labels.MatchRegexp && len(findSetMatches(m.Value)) > 0 {
vals := findSetMatches(m.Value)
toAdd := make([]labels.Label, 0, len(vals))
Expand Down

0 comments on commit 4d41d36

Please sign in to comment.