diff --git a/turbo/snapshotsync/freezeblocks/block_snapshots.go b/turbo/snapshotsync/freezeblocks/block_snapshots.go index f7b8bf07f30..b95048d2064 100644 --- a/turbo/snapshotsync/freezeblocks/block_snapshots.go +++ b/turbo/snapshotsync/freezeblocks/block_snapshots.go @@ -670,7 +670,7 @@ func (s *RoSnapshots) closeWhatNotInList(l []string) { }) } -func (s *RoSnapshots) removeOverlaps() error { +func (s *RoSnapshots) removeOverlapsAfterMerge() error { s.lockSegments() defer s.unlockSegments() @@ -1323,8 +1323,6 @@ func (br *BlockRetire) retireBlocks(ctx context.Context, minBlockNum uint64, max return ok, fmt.Errorf("DumpBlocks: %w", err) } - snapshots.removeOverlaps() - if err := snapshots.ReopenFolder(); err != nil { return ok, fmt.Errorf("reopen: %w", err) } @@ -1360,6 +1358,10 @@ func (br *BlockRetire) retireBlocks(ctx context.Context, minBlockNum uint64, max return ok, err } + // remove old garbage files + if err := snapshots.removeOverlapsAfterMerge(); err != nil { + return false, err + } return ok, nil } diff --git a/turbo/snapshotsync/freezeblocks/block_snapshots_test.go b/turbo/snapshotsync/freezeblocks/block_snapshots_test.go index f795f6f2597..d07e3ea2d2c 100644 --- a/turbo/snapshotsync/freezeblocks/block_snapshots_test.go +++ b/turbo/snapshotsync/freezeblocks/block_snapshots_test.go @@ -276,7 +276,7 @@ func TestRemoveOverlaps(t *testing.T) { require.NoError(err) require.Equal(45, len(list)) - s.removeOverlaps() + s.removeOverlapsAfterMerge() list, err = snaptype.Segments(s.dir) require.NoError(err)