mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 03:30:37 +00:00
Prevent double retiring of the same interval, prevent hiding errors (#4325)
Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
This commit is contained in:
parent
e0ac654da5
commit
b06b4b4c91
@ -898,10 +898,15 @@ func CanDeleteTo(curBlockNum uint64, snapshots *RoSnapshots) (blockTo uint64) {
|
||||
return cmp.Min(hardLimit, snapshots.BlocksAvailable()+1)
|
||||
}
|
||||
func (br *BlockRetire) RetireBlocksInBackground(ctx context.Context, blockFrom, blockTo uint64, chainID uint256.Int, lvl log.Lvl) {
|
||||
br.result = nil
|
||||
if br.working.Load() {
|
||||
// go-routine is still working
|
||||
return
|
||||
}
|
||||
if br.result != nil {
|
||||
// Prevent invocation for the same range twice, result needs to be cleared in the Result() function
|
||||
return
|
||||
}
|
||||
br.result = nil
|
||||
|
||||
br.wg.Add(1)
|
||||
go func() {
|
||||
@ -928,7 +933,7 @@ func retireBlocks(ctx context.Context, blockFrom, blockTo uint64, chainID uint25
|
||||
if err := DumpBlocks(ctx, blockFrom, blockTo, snap.DEFAULT_SEGMENT_SIZE, tmpDir, snapshots.Dir(), db, workers, lvl); err != nil {
|
||||
return fmt.Errorf("DumpBlocks: %w", err)
|
||||
}
|
||||
if err := snapshots.Reopen(); err != nil {
|
||||
if err := snapshots.ReopenSegments(); err != nil {
|
||||
return fmt.Errorf("ReopenSegments: %w", err)
|
||||
}
|
||||
idxWorkers := workers
|
||||
@ -947,6 +952,9 @@ func retireBlocks(ctx context.Context, blockFrom, blockTo uint64, chainID uint25
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := snapshots.Reopen(); err != nil {
|
||||
return fmt.Errorf("Reopen: %w", err)
|
||||
}
|
||||
// start seed large .seg of large size
|
||||
req := &proto_downloader.DownloadRequest{Items: make([]*proto_downloader.DownloadItem, 0, len(snap.AllSnapshotTypes))}
|
||||
for _, r := range ranges {
|
||||
|
Loading…
Reference in New Issue
Block a user