diff --git a/storage/local/persistence.go b/storage/local/persistence.go index ebaceeaea..a76d5de8e 100644 --- a/storage/local/persistence.go +++ b/storage/local/persistence.go @@ -706,6 +706,9 @@ func (p *persistence) checkpointSeriesMapAndHeads(fingerprintToSeries *seriesMap } } // chunkDescsOffset. + if m.series.chunkDescsOffset < 0 && m.series.persistWatermark > 0 { + panic("encountered unknown chunk desc offset in combination with positive persist watermark") + } if _, err = codable.EncodeVarint(w, int64(m.series.chunkDescsOffset+m.series.persistWatermark)); err != nil { return } diff --git a/storage/local/series.go b/storage/local/series.go index d9c36d0ef..63e4a0e2a 100644 --- a/storage/local/series.go +++ b/storage/local/series.go @@ -283,6 +283,9 @@ func (s *memorySeries) evictChunkDescs(lenToEvict int) { if lenToEvict < 1 { return } + if s.chunkDescsOffset < 0 { + panic("chunk desc eviction requested with unknown chunk desc offset") + } lenToKeep := len(s.chunkDescs) - lenToEvict s.savedFirstTime = s.firstTime() s.chunkDescsOffset += lenToEvict