Browse Source

statesync: improve rare p2p race condition (#7042)

This is intended to fix a test failure that occurs in the p2p state provider. The issue presents as the state provider timing out waiting for the consensus params response. 

The reason that this can occur is because the statesync reactor has the possibility of attempting to respond to the params request before the state provider is ready to read it. This results in the reactor hitting the `default` case seen here and then never sending on the channel. The stateprovider will then block waiting for a response and never receive one because the reactor opted not to send it.
pull/7045/head
William Banfield 3 years ago
committed by GitHub
parent
commit
243c62cc68
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions
  1. +2
    -1
      internal/statesync/reactor.go

+ 2
- 1
internal/statesync/reactor.go View File

@ -779,7 +779,8 @@ func (r *Reactor) handleParamsMessage(envelope p2p.Envelope) error {
if sp, ok := r.stateProvider.(*stateProviderP2P); ok {
select {
case sp.paramsRecvCh <- cp:
default:
case <-time.After(time.Second):
return errors.New("failed to send consensus params, stateprovider not ready for response")
}
} else {
r.Logger.Debug("received unexpected params response; using RPC state provider", "peer", envelope.From)


Loading…
Cancel
Save