From cfd4e05c9e8ea0f9bc865035e4a4760d1f294d02 Mon Sep 17 00:00:00 2001 From: Yukun Sun Date: Wed, 26 Aug 2020 23:06:27 +0800 Subject: [PATCH] fix: return a corruption error when iterator function find a chunk that is out of sequence (#7855) Signed-off-by: sunyukun Co-authored-by: sunyukun --- tsdb/chunks/head_chunks.go | 5 +++++ tsdb/head.go | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/tsdb/chunks/head_chunks.go b/tsdb/chunks/head_chunks.go index f63b1ab60..c82e38d63 100644 --- a/tsdb/chunks/head_chunks.go +++ b/tsdb/chunks/head_chunks.go @@ -633,6 +633,11 @@ func (cdm *ChunkDiskMapper) IterateAllChunks(f func(seriesRef, chunkRef uint64, } if err := f(seriesRef, chunkRef, mint, maxt, numSamples); err != nil { + if cerr, ok := err.(*CorruptionErr); ok { + cerr.Dir = cdm.dir.Name() + cerr.FileIndex = segID + return cerr + } return err } } diff --git a/tsdb/head.go b/tsdb/head.go index f1916c69e..7d4ccff23 100644 --- a/tsdb/head.go +++ b/tsdb/head.go @@ -736,7 +736,9 @@ func (h *Head) loadMmappedChunks() (map[uint64][]*mmappedChunk, error) { slice := mmappedChunks[seriesRef] if len(slice) > 0 { if slice[len(slice)-1].maxTime >= mint { - return errors.Errorf("out of sequence m-mapped chunk for series ref %d", seriesRef) + return &chunks.CorruptionErr{ + Err: errors.Errorf("out of sequence m-mapped chunk for series ref %d", seriesRef), + } } }