Browse Source

storage: Added checks for invariants

pull/2400/head
beorn7 8 years ago
parent
commit
75282b27ba
  1. 3
      storage/local/persistence.go
  2. 3
      storage/local/series.go

3
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
}

3
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

Loading…
Cancel
Save