Fix chunkDescsTotal count in case of errors.

Only increment the counter if we actually add the memory series to the
fingerprintToSeries map.
This commit is contained in:
beorn7 2015-02-27 02:21:12 +01:00
parent 1db7589081
commit 92991026bb
1 changed files with 7 additions and 2 deletions

View File

@ -680,7 +680,6 @@ func (p *persistence) loadSeriesMapAndHeads() (sm *seriesMap, err error) {
return sm, nil
}
chunkDescs := make([]*chunkDesc, numChunkDescs)
chunkDescsTotal += numChunkDescs
for i := int64(0); i < numChunkDescs; i++ {
if headChunkPersisted || i < numChunkDescs-1 {
@ -715,10 +714,16 @@ func (p *persistence) loadSeriesMapAndHeads() (sm *seriesMap, err error) {
return sm, nil
}
chunkDescs[i] = newChunkDesc(chunk)
chunkDescsTotal-- // Avoid double-counting by newChunkDesc.
}
}
chunkDescsTotal += numChunkDescs
if !headChunkPersisted {
// In this case, we have created a chunkDesc with
// newChunkDesc, which will count itself automatically.
// Correct for that by decrementing the count.
chunkDescsTotal--
}
fingerprintToSeries[clientmodel.Fingerprint(fp)] = &memorySeries{
metric: clientmodel.Metric(metric),
chunkDescs: chunkDescs,