Skip to content

Commit

Permalink
fix: handle panic in podsi indexing (#1868)
Browse files Browse the repository at this point in the history
fix: handle panic in podsi indexing
  • Loading branch information
ischasny authored Jan 11, 2024
1 parent a0b52f6 commit 019b67d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions piecedirectory/piecedirectory.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ func (ps *PieceDirectory) addIndexForPiece(ctx context.Context, pieceCid cid.Cid
if err != nil {
return fmt.Errorf("getting reader over piece %s: %w", pieceCid, err)
}

defer reader.Close() //nolint:errcheck

// Try to parse data as containing a data segment index
Expand Down Expand Up @@ -405,6 +406,15 @@ func (cr *countingReader) Read(p []byte) (n int, err error) {
}

func parsePieceWithDataSegmentIndex(pieceCid cid.Cid, unpaddedSize int64, r types.SectionReader) ([]model.Record, error) {
defer func() {
// This is a temporary workaround to handle "slice bounds out of range" errors in podsi indexing.
// The bug affects a minor number of deals, so recovering here will help to unblock the users.
// TODO: remove this recover when the underlying bug is figured out and fixed.
if err := recover(); err != nil {
log.Errorw("Recovered from panic and skipped indexing the piece.", "piece", pieceCid, "error", err)
}
}()

concurrency := runtime.NumCPU()
if concurrency < PodsiMinConcurrency {
concurrency = PodsiMinConcurrency
Expand Down

0 comments on commit 019b67d

Please sign in to comment.