From e969346e3ea0912cbb7ec374b940250a22c626e9 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Mon, 16 Nov 2020 13:30:41 +0200 Subject: [PATCH] app/vmselect/prometheus: fix deadlock in `/api/v1/series` on a time range exceeding one day --- app/vmselect/prometheus/prometheus.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/vmselect/prometheus/prometheus.go b/app/vmselect/prometheus/prometheus.go index 111231b92..bb49641f7 100644 --- a/app/vmselect/prometheus/prometheus.go +++ b/app/vmselect/prometheus/prometheus.go @@ -962,21 +962,19 @@ func SeriesHandler(startTime time.Time, at *auth.Token, w http.ResponseWriter, r bw := bufferedwriter.Get(w) defer bufferedwriter.Put(bw) resultsCh := make(chan *quicktemplate.ByteBuffer) - doneCh := make(chan struct{}) go func() { for i := range mns { bb := quicktemplate.AcquireByteBuffer() writemetricNameObject(bb, &mns[i]) resultsCh <- bb } - close(doneCh) + close(resultsCh) }() // WriteSeriesResponse must consume all the data from resultsCh. WriteSeriesResponse(bw, isPartial, resultsCh) if err := bw.Flush(); err != nil { return err } - <-doneCh seriesDuration.UpdateDuration(startTime) return nil }