From 2fad91d25a957d4329140889ed501957c72c3651 Mon Sep 17 00:00:00 2001 From: beorn7 Date: Fri, 6 Oct 2017 14:19:30 +0200 Subject: [PATCH] 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. --- storage/local/storage.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/storage/local/storage.go b/storage/local/storage.go index e8039faa0..c1caef67e 100644 --- a/storage/local/storage.go +++ b/storage/local/storage.go @@ -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).