forked from thanos-io/thanos
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PLAT-111995] detect and prevent polluted data to return to user
Signed-off-by: Yi Jin <[email protected]>
- Loading branch information
Showing
3 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright (c) The Thanos Authors. | ||
// Licensed under the Apache License 2.0. | ||
|
||
package store | ||
|
||
import ( | ||
"github.com/prometheus/prometheus/model/labels" | ||
"github.com/thanos-io/thanos/pkg/store/storepb" | ||
"strings" | ||
) | ||
|
||
// So far we found this is a bug in prometheus tsdb code when OOO is enabled. | ||
// This is a workaround to detect the issue when tsdb selects irrelevant matched data. | ||
// See https://github.com/thanos-io/thanos/issues/7481 | ||
func detectCorruptLabels(labels labels.Labels, matchers []storepb.LabelMatcher) bool { | ||
for _, m := range matchers { | ||
v := labels.Get(m.Name) | ||
if (m.Type == storepb.LabelMatcher_EQ && v != m.Value) || | ||
(m.Type == storepb.LabelMatcher_NEQ && v == m.Value) { | ||
return true | ||
} | ||
} | ||
return false | ||
} | ||
|
||
func requestMatches(matchers []storepb.LabelMatcher) string { | ||
var b strings.Builder | ||
for _, m := range matchers { | ||
b.WriteString(m.String()) | ||
} | ||
return b.String() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters