mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-23 20:37:12 +01:00
lib/storage: verify that blocks in a single part are sorted by TSID when reading sequential blocks from the part
This may help narrowing down the issue https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2082
This commit is contained in:
parent
ea87f21e23
commit
00b7c97d2a
@ -175,7 +175,7 @@ func (bsr *blockStreamReader) InitFromFilePart(path string) error {
|
||||
timestampsFile.MustClose()
|
||||
valuesFile.MustClose()
|
||||
indexFile.MustClose()
|
||||
return fmt.Errorf("cannot unmarshal metaindex rows from inmemoryPart: %w", err)
|
||||
return fmt.Errorf("cannot unmarshal metaindex rows from file part %q: %w", metaindexPath, err)
|
||||
}
|
||||
|
||||
bsr.path = path
|
||||
@ -213,16 +213,19 @@ func (bsr *blockStreamReader) NextBlock() bool {
|
||||
if bsr.err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
tsidPrev := bsr.Block.bh.TSID
|
||||
bsr.Block.Reset()
|
||||
|
||||
err := bsr.readBlock()
|
||||
if err == nil {
|
||||
if bsr.Block.bh.RowsCount > 0 {
|
||||
return true
|
||||
if bsr.Block.bh.TSID.Less(&tsidPrev) {
|
||||
bsr.err = fmt.Errorf("possible data corruption: the next TSID=%v is smaller than the previous TSID=%v", &bsr.Block.bh.TSID, &tsidPrev)
|
||||
return false
|
||||
}
|
||||
bsr.err = fmt.Errorf("invalid block read with zero rows; block=%+v", &bsr.Block)
|
||||
return false
|
||||
if bsr.Block.bh.RowsCount == 0 {
|
||||
bsr.err = fmt.Errorf("invalid block read with zero rows; block=%+v", &bsr.Block)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
if err == io.EOF {
|
||||
bsr.err = io.EOF
|
||||
|
Loading…
Reference in New Issue
Block a user