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. // 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 { if _, err = codable.EncodeVarint(w, int64(m.series.chunkDescsOffset+m.series.persistWatermark)); err != nil {
return return
} }

3
storage/local/series.go

@ -283,6 +283,9 @@ func (s *memorySeries) evictChunkDescs(lenToEvict int) {
if lenToEvict < 1 { if lenToEvict < 1 {
return return
} }
if s.chunkDescsOffset < 0 {
panic("chunk desc eviction requested with unknown chunk desc offset")
}
lenToKeep := len(s.chunkDescs) - lenToEvict lenToKeep := len(s.chunkDescs) - lenToEvict
s.savedFirstTime = s.firstTime() s.savedFirstTime = s.firstTime()
s.chunkDescsOffset += lenToEvict s.chunkDescsOffset += lenToEvict

Loading…
Cancel
Save