From 1b6edf499a34fc5ac9b27c882c1df1704ddc4ed9 Mon Sep 17 00:00:00 2001 From: Mark Holt <135143369+mh0lt@users.noreply.github.com> Date: Fri, 21 Feb 2025 14:17:30 +0000 Subject: [PATCH] set ready on file open as well as download complete (#13901) fixes: https://github.com/erigontech/erigon/issues/13897 --- turbo/snapshotsync/snapshots.go | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/turbo/snapshotsync/snapshots.go b/turbo/snapshotsync/snapshots.go index 0d701468ff3..48b10241cb5 100644 --- a/turbo/snapshotsync/snapshots.go +++ b/turbo/snapshotsync/snapshots.go @@ -601,12 +601,11 @@ func (s *RoSnapshots) VisibleBlocksAvailable(t snaptype.Enum) uint64 { } func (s *RoSnapshots) DownloadComplete() { - if !s.SegmentsReady() { - return - } wasReady := s.downloadReady.Swap(true) if !wasReady { - s.ready.set() + if s.SegmentsReady() { + s.ready.set() + } } } @@ -987,7 +986,12 @@ func (s *RoSnapshots) InitSegments(fileNames []string) error { } s.recalcVisibleFiles() - s.segmentsReady.Store(true) + wasReady := s.segmentsReady.Swap(true) + if !wasReady { + if s.downloadReady.Load() { + s.ready.set() + } + } return nil } @@ -1152,7 +1156,12 @@ func (s *RoSnapshots) OpenFolder() error { } s.recalcVisibleFiles() - s.segmentsReady.Store(true) + wasReady := s.segmentsReady.Swap(true) + if !wasReady { + if s.downloadReady.Load() { + s.ready.set() + } + } return nil }