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:
beorn7 2017-10-06 14:19:30 +02:00
parent a5412cfc59
commit 2fad91d25a
1 changed files with 4 additions and 1 deletions

View File

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