diff --git a/pkg/network/discovery.go b/pkg/network/discovery.go index 21704f452..9f9d80957 100644 --- a/pkg/network/discovery.go +++ b/pkg/network/discovery.go @@ -225,15 +225,22 @@ func (d *DefaultDiscovery) run() { } d.lock.Unlock() default: // Empty pool + var added int d.lock.Lock() for _, addr := range d.seeds { if !d.connectedAddrs[addr] { delete(d.badAddrs, addr) d.unconnectedAddrs[addr] = connRetries d.pushToPoolOrDrop(addr) + added++ } } d.lock.Unlock() + // The pool is empty, but all seed nodes are already connected, + // we can end up in an infinite loop here, so drop the request. + if added == 0 { + requested = 0 + } } } if !ok {