mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
Add missing lock to ExtractSelectors
Now that we are parallel walking we need to ensure that the visitor methods are concurrent-safe. Surprisingly this doesn't show up in `-race Fixes https://github.com/jacksontj/promxy/issues/579
This commit is contained in:
parent
2b58f7d126
commit
a95115a6da
|
@ -382,11 +382,16 @@ func Walk(ctx context.Context, v Visitor, s *EvalStmt, node Node, path []Node, n
|
|||
}
|
||||
|
||||
func ExtractSelectors(expr Expr) [][]*labels.Matcher {
|
||||
var selectors [][]*labels.Matcher
|
||||
var (
|
||||
selectors [][]*labels.Matcher
|
||||
l sync.Mutex
|
||||
)
|
||||
Inspect(context.TODO(), &EvalStmt{Expr: expr}, func(node Node, _ []Node) error {
|
||||
vs, ok := node.(*VectorSelector)
|
||||
if ok {
|
||||
l.Lock()
|
||||
selectors = append(selectors, vs.LabelMatchers)
|
||||
l.Unlock()
|
||||
}
|
||||
return nil
|
||||
}, nil)
|
||||
|
|
Loading…
Reference in a new issue