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.
This commit is contained in:
beorn7 2016-07-07 16:17:38 +02:00
parent b16f49bb44
commit 2a75b15328
1 changed files with 4 additions and 0 deletions

View File

@ -362,6 +362,10 @@ func (p *persistence) sanitizeSeries(
) )
numMemChunkDescs.Sub(float64(keepIdx)) numMemChunkDescs.Sub(float64(keepIdx))
atomic.AddInt64(&numMemChunks, int64(-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:]...) s.chunkDescs = append(cds, s.chunkDescs[keepIdx:]...)
return fp, true return fp, true
} }