Avoid blocking in the logThrottling loop
The timer semantics is really hard. The simple pattern as given in the godoc for the time package assumes we are not elsewhere consuming from the timer's channel. However, exactly that can happen here with the right sequence of events. Thus, we have to drain the channel only if it has something to drain.
This commit is contained in:
parent
a5412cfc59
commit
2fad91d25a
|
@ -999,7 +999,10 @@ func (s *MemorySeriesStorage) logThrottling() {
|
|||
select {
|
||||
case <-s.throttled:
|
||||
if !timer.Stop() {
|
||||
<-timer.C
|
||||
select {
|
||||
case <-timer.C:
|
||||
default:
|
||||
}
|
||||
score, _ := s.getPersistenceUrgencyScore()
|
||||
log.
|
||||
With("urgencyScore", score).
|
||||
|
|
Loading…
Reference in New Issue