Skip to content

Commit

Permalink
seg: make prune run as an rotx reader (#12396)
Browse files Browse the repository at this point in the history
Try closing and removing canDelete files only when closing rotx. 

reason: `merge` and `prune`, running as rotx reader, will increase
`refCount`
  • Loading branch information
stevemilk authored Dec 6, 2024
1 parent e2d00e3 commit 9c351b1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
3 changes: 0 additions & 3 deletions turbo/snapshotsync/merger.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,6 @@ func (m *Merger) integrateMergedDirtyFiles(snapshots *RoSnapshots, in, out map[s
for _, delSeg := range delSegs {
dirtySegments.Delete(delSeg)
delSeg.canDelete.Store(true)
if delSeg.refcount.Load() == 0 {
delSeg.closeAndRemoveFiles()
}
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions turbo/snapshotsync/snapshots.go
Original file line number Diff line number Diff line change
Expand Up @@ -1291,9 +1291,6 @@ func (s *RoSnapshots) delete(fileName string) error {
continue
}
sn.canDelete.Store(true)
if sn.refcount.Load() == 0 {
sn.closeAndRemoveFiles()
}
delSeg = sn
dirtySegments = s.dirty[t]
findDelSeg = false
Expand All @@ -1314,6 +1311,10 @@ func (s *RoSnapshots) Delete(fileName string) error {
if s == nil {
return nil
}

v := s.View()
defer v.Close()

defer s.recalcVisibleFiles()
if err := s.delete(fileName); err != nil {
return fmt.Errorf("can't delete file: %w", err)
Expand Down

0 comments on commit 9c351b1

Please sign in to comment.