From 92991026bb83020f09bc1eee212bfc6daaabd41f Mon Sep 17 00:00:00 2001 From: beorn7 Date: Fri, 27 Feb 2015 02:21:12 +0100 Subject: [PATCH] Fix chunkDescsTotal count in case of errors. Only increment the counter if we actually add the memory series to the fingerprintToSeries map. --- storage/local/persistence.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/storage/local/persistence.go b/storage/local/persistence.go index 15b318228..ca6f822b4 100644 --- a/storage/local/persistence.go +++ b/storage/local/persistence.go @@ -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,