mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
vmalert: make group.ID() thread-safe (#1726)
Commit fixes potential race condition when group update and generating of ID() happens simultaneously. Signed-off-by: hagen1778 <roman@victoriametrics.com>
This commit is contained in:
parent
dcd881bb7a
commit
bdfac4ff53
1 changed files with 3 additions and 0 deletions
|
@ -123,6 +123,9 @@ func (g *Group) newRule(qb datasource.QuerierBuilder, rule config.Rule) Rule {
|
|||
// ID return unique group ID that consists of
|
||||
// rules file and group name
|
||||
func (g *Group) ID() uint64 {
|
||||
g.mu.RLock()
|
||||
defer g.mu.RUnlock()
|
||||
|
||||
hash := fnv.New64a()
|
||||
hash.Write([]byte(g.File))
|
||||
hash.Write([]byte("\xff"))
|
||||
|
|
Loading…
Reference in a new issue