mirror of
https://github.com/prometheus/prometheus.git
synced 2026-05-28 04:02:21 -04:00
Use Set in GetOrSet to enforce proper lock ordering
Signed-off-by: Kyle Eckhart <kgeckhart@users.noreply.github.com>
This commit is contained in:
parent
33afbb799a
commit
9c6b468ae3
1 changed files with 1 additions and 8 deletions
|
|
@ -260,20 +260,13 @@ func (s *stripeSeries) GetOrSet(hash uint64, series *memSeries) (*memSeries, boo
|
|||
hashLock := s.hashLock(hash)
|
||||
|
||||
s.locks[hashLock].Lock()
|
||||
// If it already exists in hashes, return it.
|
||||
if prev := s.hashes[hashLock].Get(hash, series.lset); prev != nil {
|
||||
s.locks[hashLock].Unlock()
|
||||
return prev, false
|
||||
}
|
||||
s.hashes[hashLock].Set(hash, series)
|
||||
s.locks[hashLock].Unlock()
|
||||
|
||||
refLock := s.refLock(series.ref)
|
||||
|
||||
s.locks[refLock].Lock()
|
||||
s.series[refLock][series.ref] = series
|
||||
s.locks[refLock].Unlock()
|
||||
|
||||
s.Set(hash, series)
|
||||
return series, true
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue