From 9a75b5f84b01b891c7a2c6a003c3be8b83d97bcd Mon Sep 17 00:00:00 2001 From: Krasi Georgiev <8903888+krasi-georgiev@users.noreply.github.com> Date: Mon, 20 Jul 2020 18:23:18 +0300 Subject: [PATCH] Avoid panic when the headChunk is nil during isolation. Signed-off-by: Krasi Georgiev <8903888+krasi-georgiev@users.noreply.github.com> --- tsdb/head.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tsdb/head.go b/tsdb/head.go index 0a16671ea..536487a2f 100644 --- a/tsdb/head.go +++ b/tsdb/head.go @@ -2186,10 +2186,8 @@ func (s *memSeries) iterator(id int, isoState *isolationState, chunkDiskMapper * previousSamples += int(d.numSamples) } } - // mmappedChunks does not contain the last chunk. Hence check it separately. - if len(s.mmappedChunks) < ix { - previousSamples += s.headChunk.chunk.NumSamples() - } else { + + if s.headChunk != nil { totalSamples += s.headChunk.chunk.NumSamples() }