diff --git a/eth/downloader/fetchers_concurrent.go b/eth/downloader/fetchers_concurrent.go index 649aa27615..87f34dcca1 100644 --- a/eth/downloader/fetchers_concurrent.go +++ b/eth/downloader/fetchers_concurrent.go @@ -33,6 +33,9 @@ import ( // to each request. Failing to do so is considered a protocol violation. var timeoutGracePeriod = 2 * time.Minute +// peersRetryInterval is the retry interval when all peers cannot get the request data. +var peersRetryInterval = 100 * time.Millisecond + // typedQueue is an interface defining the adaptor needed to translate the type // specific downloader/queue schedulers into the type-agnostic general concurrent // fetcher algorithm calls. @@ -195,6 +198,10 @@ func (d *Downloader) concurrentFetch(queue typedQueue, beaconMode bool) error { // to the queue, that is async, and we can do better here by // immediately pushing the unfulfilled requests. queue.unreserve(peer.id) // TODO(karalabe): This needs a non-expiration method + //reset progressed + if len(pending) == 0 { + progressed = false + } continue } pending[peer.id] = req @@ -212,6 +219,12 @@ func (d *Downloader) concurrentFetch(queue typedQueue, beaconMode bool) error { if !progressed && !throttled && len(pending) == 0 && len(idles) == d.peers.Len() && queued > 0 && !beaconMode { return errPeersUnavailable } + // Retry the unreserved task in next loop + if len(pending) == 0 && queued > 0 && beaconMode { + log.Warn("All idle peers are not valid for current task, will retry ...") + time.Sleep(peersRetryInterval) + continue + } } // Wait for something to happen select { diff --git a/eth/downloader/fetchers_concurrent_bodies.go b/eth/downloader/fetchers_concurrent_bodies.go index 9440972c6d..7073894d7a 100644 --- a/eth/downloader/fetchers_concurrent_bodies.go +++ b/eth/downloader/fetchers_concurrent_bodies.go @@ -74,7 +74,7 @@ func (q *bodyQueue) unreserve(peer string) int { // request is responsible for converting a generic fetch request into a body // one and sending it to the remote peer for fulfillment. func (q *bodyQueue) request(peer *peerConnection, req *fetchRequest, resCh chan *eth.Response) (*eth.Request, error) { - peer.log.Trace("Requesting new batch of bodies", "count", len(req.Headers), "from", req.Headers[0].Number) + peer.log.Debug("Requesting new batch of bodies", "count", len(req.Headers), "from", req.Headers[0].Number) if q.bodyFetchHook != nil { q.bodyFetchHook(req.Headers) } diff --git a/go.mod b/go.mod index 261f0ff4e8..b74185c9c9 100644 --- a/go.mod +++ b/go.mod @@ -82,7 +82,6 @@ require ( github.com/aws/aws-sdk-go-v2/service/sts v1.1.1 // indirect github.com/aws/smithy-go v1.14.2 // indirect github.com/beorn7/perks v1.0.1 // indirect - github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 // indirect github.com/cespare/xxhash v1.1.0 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/cockroachdb/errors v1.9.1 // indirect diff --git a/go.sum b/go.sum index 1e90b92e64..5e533c6eee 100644 --- a/go.sum +++ b/go.sum @@ -170,7 +170,6 @@ github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= github.com/btcsuite/btcd/btcutil v1.1.2 h1:XLMbX8JQEiwMcYft2EGi8zPUkoa0abKIU6/BJSRsjzQ= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= -github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= github.com/btcsuite/btcutil v0.0.0-20190207003914-4c204d697803/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg=