mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-13 13:11:37 +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
54ee71e16d
commit
e3277918e4
@ -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