Skip to content

Commit

Permalink
e3: remove overlapped files only after merge (part 2) (#10514)
Browse files Browse the repository at this point in the history
  • Loading branch information
AskAlexSharov authored May 28, 2024
1 parent f3ab713 commit 708078a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions turbo/snapshotsync/freezeblocks/block_snapshots.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion turbo/snapshotsync/freezeblocks/block_snapshots_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 708078a

Please sign in to comment.