From 2a75b15328c44ec9c6cb0be2bac76d97e2232f42 Mon Sep 17 00:00:00 2001 From: beorn7 Date: Thu, 7 Jul 2016 16:17:38 +0200 Subject: [PATCH] Crash recovery: Fix an edge case. If the chunks of a series in the checkpoint are all older then the latest chunk on disk, the head chunk is persisted and therefore has to be declared closed. It would be great to have a test for this, but that would require more plumbing, subject of #447. --- storage/local/crashrecovery.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/storage/local/crashrecovery.go b/storage/local/crashrecovery.go index 17626c07c..2f695f10b 100644 --- a/storage/local/crashrecovery.go +++ b/storage/local/crashrecovery.go @@ -362,6 +362,10 @@ func (p *persistence) sanitizeSeries( ) numMemChunkDescs.Sub(float64(keepIdx)) atomic.AddInt64(&numMemChunks, int64(-keepIdx)) + if keepIdx == len(s.chunkDescs) { + // No chunks from series file left, head chunk is evicted, so declare it closed. + s.headChunkClosed = true + } s.chunkDescs = append(cds, s.chunkDescs[keepIdx:]...) return fp, true }