Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start the monitor after an unsupported is detected #3

Open
wants to merge 1 commit into
base: catchup-fix
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions catchup/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ type Service struct {
deadlineTimeout time.Duration
blockValidationPool execpool.BacklogPool

haveUnsupported chan struct{}

// suspendForCatchpointWriting defines whether we've run into a state where the ledger is currently busy writing the
// catchpoint file. If so, we want to suspend the catchup process until the catchpoint file writing is complete,
// and resume from there without stopping the catchup timer.
Expand Down Expand Up @@ -134,6 +136,7 @@ func MakeService(log logging.Logger, config config.Local, net network.GossipNode

// Start the catchup service
func (s *Service) Start() {
s.haveUnsupported = make(chan struct{})
s.ctx, s.cancel = context.WithCancel(context.Background())
atomic.StoreUint32(&s.initialSyncNotified, 0)
s.InitialSyncDone = make(chan struct{})
Expand Down Expand Up @@ -511,6 +514,12 @@ func (s *Service) pipelinedFetch(seedLookback uint64) {
// happens.
func (s *Service) unsupportedRoundMonitor() {
defer s.workers.Done()
select {
case <-s.ctx.Done():
return
case <-s.haveUnsupported:
}

for {
nextRound := s.ledger.NextRound()
if s.roundIsNotSupported(nextRound) {
Expand Down Expand Up @@ -749,6 +758,10 @@ func (s *Service) roundIsNotSupported(nextRound basics.Round) bool {
}

s.log.Infof("Catchup Service: round %d is not approved, requires upgrading to unsupported %s in round %d. Service will stop once the last supported round is added to the ledger.", nextRound, bh.NextProtocol, bh.NextProtocolSwitchOn)
select {
case s.haveUnsupported <- struct{}{}:
default:
}
return true
}

Expand Down