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

Signed-off-by: machine424 <ayoubmrini424@gmail.com>
This commit is contained in:
machine424 2023-11-13 13:26:02 +01:00
parent 08c17df244
commit 413b713aa8
No known key found for this signature in database
GPG key ID: A4B001A4FDEE017D
2 changed files with 11 additions and 4 deletions

View file

@ -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.

View file

@ -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 {