Skip to content

Commit

Permalink
block files: idxAvailability must rely on visibleFiles instead of ato…
Browse files Browse the repository at this point in the history
…mics (#12078)

reason: visible files guarantee consistency - between file types
(because hide under same mutex). `maxVisibleBlock` atomic - doesn't give
such guaranty (mutex doesn't guard them).

for: #12069
  • Loading branch information
AskAlexSharov authored Sep 24, 2024
1 parent df3cc96 commit 2b873ff
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions turbo/snapshotsync/freezeblocks/block_snapshots.go
Original file line number Diff line number Diff line change
Expand Up @@ -663,8 +663,10 @@ func (s *RoSnapshots) idxAvailability() uint64 {
if !s.HasType(segtype.Type()) {
return true
}
maxIdx = value.maxVisibleBlock.Load()
return false // all types of segments have the same height. stop here
if len(value.VisibleSegments) > 0 {
maxIdx = value.VisibleSegments[len(value.VisibleSegments)-1].to - 1
}
return false // all types of visible-segments have the same height. stop here
})

return maxIdx
Expand Down
4 changes: 3 additions & 1 deletion turbo/snapshotsync/freezeblocks/caplin_snapshots.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,11 @@ func (s *CaplinSnapshots) recalcVisibleFiles() {
s.BeaconBlocks.VisibleSegments = getNewVisibleSegments(s.BeaconBlocks.DirtySegments)
s.BlobSidecars.VisibleSegments = getNewVisibleSegments(s.BlobSidecars.DirtySegments)

var maxIdx uint64
if len(s.BeaconBlocks.VisibleSegments) > 0 {
s.BeaconBlocks.maxVisibleBlock.Store(s.BeaconBlocks.VisibleSegments[len(s.BeaconBlocks.VisibleSegments)-1].to - 1)
maxIdx = s.BeaconBlocks.VisibleSegments[len(s.BeaconBlocks.VisibleSegments)-1].to - 1
}
s.BeaconBlocks.maxVisibleBlock.Store(maxIdx)
}

func (s *CaplinSnapshots) idxAvailability() uint64 {
Expand Down

0 comments on commit 2b873ff

Please sign in to comment.