Snapshots: corner cases when .seg exists and .idx doesn't (#3731)

This commit is contained in:
Alex Sharov 2022-03-18 13:36:59 +07:00 committed by GitHub
parent b73415fb3f
commit a04fa4838d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -600,12 +600,17 @@ func BuildIndices(ctx context.Context, s *RoSnapshots, snapshotDir *dir.Rw, chai
return err
}
if err := s.Txs.View(func(segments []*TxnSegment) error {
for i, sn := range segments {
if sn.From < from {
continue
}
return s.Bodies.View(func(bodySegments []*BodySegment) error {
for i, sn := range segments {
if sn.From < from {
continue
}
if bodySegments[i].idxBodyNumber == nil {
log.Info("[snapshots] Segment has no index, skip", "seg", bodySegments[i].seg.FilePath())
continue
}
if err := s.Bodies.View(func(bodySegments []*BodySegment) error {
// build txs idx
gg := bodySegments[i].seg.MakeGetter()
buf, _ := gg.Next(nil)
@ -633,13 +638,9 @@ func BuildIndices(ctx context.Context, s *RoSnapshots, snapshotDir *dir.Rw, chai
return err
}
return nil
}); err != nil {
return nil
}
}
return nil
return nil
})
}); err != nil {
return nil
}