mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/storage: prevent possible race condition when all the goroutines exit Storage.AddRows, before goroutines other goroutines are blocked on searchTSIDsCond inside Storage.searchTSIDs
This condition may occur after the following sequence of events: 1) A goroutine enters the loop body when len(addRowsConcurrencyCh) == cap(addRowsConcurrencyCh) inside Storage.searchTSIDs. 2) All the goroutines return from Storage.AddRows. 3) The goroutine from step 1 blocks on searchTSIDsCond.Wait() inside the loop body. The goroutine remains blocked until the next call to Storage.AddRows, which calls searchTSIDsCond.Signal(). This may take indefinite time.
This commit is contained in:
parent
71c3266fca
commit
754eac676d
1 changed files with 2 additions and 0 deletions
|
@ -1112,8 +1112,10 @@ func (s *Storage) AddRows(mrs []MetricRow, precisionBits uint8) error {
|
|||
putRawRows(rr)
|
||||
|
||||
// Notify blocked goroutines at Storage.searchTSIDs that they may proceed with their work.
|
||||
searchTSIDsCondLock.Lock()
|
||||
<-addRowsConcurrencyCh
|
||||
searchTSIDsCond.Signal()
|
||||
searchTSIDsCondLock.Unlock()
|
||||
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue