remote/storage.go: adjust Storage.Notify() to avoid a race condition with Storage.ApplyConfig()

Signed-off-by: machine424 <ayoubmrini424@gmail.com>
pull/13135/head
machine424 2 years ago
parent 08c17df244
commit 413b713aa8
No known key found for this signature in database
GPG Key ID: A4B001A4FDEE017D
  1. 5
      storage/remote/storage.go
  2. 10
      storage/remote/write.go

@ -77,10 +77,7 @@ func NewStorage(l log.Logger, reg prometheus.Registerer, stCallback startTimeCal
}
func (s *Storage) Notify() {
for _, q := range s.rws.queues {
// These should all be non blocking
q.watcher.Notify()
}
s.rws.Notify()
}
// ApplyConfig updates the state as the new config requires.

@ -121,6 +121,16 @@ func (rws *WriteStorage) run() {
}
}
func (rws *WriteStorage) Notify() {
rws.mtx.Lock()
defer rws.mtx.Unlock()
for _, q := range rws.queues {
// These should all be non blocking
q.watcher.Notify()
}
}
// ApplyConfig updates the state as the new config requires.
// Only stop & create queues which have changes.
func (rws *WriteStorage) ApplyConfig(conf *config.Config) error {

Loading…
Cancel
Save