From 31e94803dc1318784ff3bd2653c0bde254458c9e Mon Sep 17 00:00:00 2001 From: Alex Sharov <AskAlexSharov@gmail.com> Date: Tue, 24 May 2022 11:00:55 +0700 Subject: [PATCH] SnapshotIndex: Add more context to panic #4245 --- turbo/snapshotsync/block_snapshots.go | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/turbo/snapshotsync/block_snapshots.go b/turbo/snapshotsync/block_snapshots.go index d10785ae67..e72f4ad13f 100644 --- a/turbo/snapshotsync/block_snapshots.go +++ b/turbo/snapshotsync/block_snapshots.go @@ -17,6 +17,7 @@ import ( "github.com/holiman/uint256" common2 "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon-lib/common/cmp" + "github.com/ledgerwatch/erigon-lib/common/dbg" "github.com/ledgerwatch/erigon-lib/compress" proto_downloader "github.com/ledgerwatch/erigon-lib/gointerfaces/downloader" "github.com/ledgerwatch/erigon-lib/kv" @@ -1290,7 +1291,7 @@ var EmptyTxHash = common.Hash{} func TransactionsIdx(ctx context.Context, chainID uint256.Int, blockFrom, blockTo uint64, snapDir string, tmpDir string, lvl log.Lvl) (err error) { defer func() { if rec := recover(); rec != nil { - err = fmt.Errorf("TransactionsIdx: at=%d-%d, %v", blockFrom, blockTo, rec) + err = fmt.Errorf("TransactionsIdx: at=%d-%d, %v, %s", blockFrom, blockTo, rec, dbg.Stack()) } }() var expectedCount, firstTxID uint64 @@ -1455,7 +1456,14 @@ RETRY: } // HeadersIdx - headerHash -> offset (analog of kv.HeaderNumber) -func HeadersIdx(ctx context.Context, segmentFilePath string, firstBlockNumInSegment uint64, tmpDir string, lvl log.Lvl) error { +func HeadersIdx(ctx context.Context, segmentFilePath string, firstBlockNumInSegment uint64, tmpDir string, lvl log.Lvl) (err error) { + defer func() { + if rec := recover(); rec != nil { + _, fName := filepath.Split(segmentFilePath) + err = fmt.Errorf("HeadersIdx: at=%s, %v, %s", fName, rec, dbg.Stack()) + } + }() + d, err := compress.NewDecompressor(segmentFilePath) if err != nil { return err @@ -1479,7 +1487,14 @@ func HeadersIdx(ctx context.Context, segmentFilePath string, firstBlockNumInSegm return nil } -func BodiesIdx(ctx context.Context, segmentFilePath string, firstBlockNumInSegment uint64, tmpDir string, lvl log.Lvl) error { +func BodiesIdx(ctx context.Context, segmentFilePath string, firstBlockNumInSegment uint64, tmpDir string, lvl log.Lvl) (err error) { + defer func() { + if rec := recover(); rec != nil { + _, fName := filepath.Split(segmentFilePath) + err = fmt.Errorf("BodiesIdx: at=%s, %v, %s", fName, rec, dbg.Stack()) + } + }() + num := make([]byte, 8) d, err := compress.NewDecompressor(segmentFilePath) -- GitLab