Merge pull request #2116 from prometheus/beorn7/fix

Add guard against non-monotonic samples in series
This commit is contained in:
Björn Rabenstein 2016-10-26 22:50:10 +02:00 committed by GitHub
commit c1ae61a2cc
1 changed files with 5 additions and 0 deletions

View File

@ -14,6 +14,7 @@
package local package local
import ( import (
"fmt"
"sort" "sort"
"sync" "sync"
"time" "time"
@ -496,6 +497,10 @@ func (s *memorySeries) preloadChunksForRange(
if throughIdx == len(s.chunkDescs) { if throughIdx == len(s.chunkDescs) {
throughIdx-- throughIdx--
} }
if fromIdx > throughIdx {
// Guard against nonsensical result. The caller will quarantine the series with a meaningful log entry.
return nopIter, fmt.Errorf("fromIdx=%d is greater than throughIdx=%d, likely caused by data corruption", fromIdx, throughIdx)
}
pinIndexes := make([]int, 0, throughIdx-fromIdx+1) pinIndexes := make([]int, 0, throughIdx-fromIdx+1)
for i := fromIdx; i <= throughIdx; i++ { for i := fromIdx; i <= throughIdx; i++ {