Skip to content

Commit

Permalink
Handle no acceptable summaries (#110)
Browse files Browse the repository at this point in the history
* handle no acceptable summaries

* only handle case where state syncer did not start

* more comments
  • Loading branch information
patrick-ogrady authored Mar 22, 2023
1 parent a924fb5 commit c8307fb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
1 change: 1 addition & 0 deletions vm/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ var (
ErrNotReady = errors.New("not ready")
ErrStateMissing = errors.New("state missing")
ErrMessageMissing = errors.New("message missing")
ErrStateSyncing = errors.New("state still syncing")
)
25 changes: 23 additions & 2 deletions vm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,10 +376,30 @@ func (vm *VM) SetState(_ context.Context, state snow.State) error {
vm.Logger().Info("state sync started")
return nil
case snow.Bootstrapping:
vm.Logger().Info("bootstrapping started")
syncStarted := vm.stateSyncClient.Started()
if !syncStarted {
// We must check if we finished syncing before starting bootstrapping.
// This should only ever occur if we began a state sync, restarted, and
// were unable to find any acceptable summaries.
syncing, err := vm.GetDiskIsSyncing()
if err != nil {
vm.Logger().Error("could not determine if syncing", zap.Error(err))
return err
}
if syncing {
vm.Logger().Error("cannot start bootstrapping", zap.Error(ErrStateSyncing))
// This is a fatal error that will require retrying sync or deleting the
// node database.
return ErrStateSyncing
}
// If we weren't previously syncing, we force state syncer completion so
// that the node will mark itself as ready.
vm.stateSyncClient.ForceDone()
}
vm.Logger().Info("bootstrapping started", zap.Bool("state sync started", syncStarted))
return vm.onBootstrapStarted()
case snow.NormalOp:
vm.Logger().Info("normal operation started")
vm.Logger().Info("normal operation started", zap.Bool("state sync started", vm.stateSyncClient.Started()))
return vm.onNormalOperationsStarted()
default:
return snow.ErrUnknownState
Expand All @@ -392,6 +412,7 @@ func (vm *VM) onBootstrapStarted() error {
return nil
}

// ForceReady is used in integration testing
func (vm *VM) ForceReady() {
// Only works if haven't already started syncing
vm.stateSyncClient.ForceDone()
Expand Down

0 comments on commit c8307fb

Please sign in to comment.