Skip to content

Commit

Permalink
remove peers with network errors from worker pool
Browse files Browse the repository at this point in the history
  • Loading branch information
haikoschol committed Nov 6, 2024
1 parent 3af5e2a commit 3accdcb
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions dot/sync/worker_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ import (
"context"
"errors"
"fmt"
"io"
"sync"
"time"

"github.com/ChainSafe/gossamer/dot/network"

"github.com/libp2p/go-libp2p/core/peer"
)

Expand Down Expand Up @@ -331,9 +334,12 @@ func (w *workerPool) handleFailedTask(tr TaskResult, batchID BatchID, batchResul

if oldTr, ok := w.statuses[batchID].Failed[tID]; ok {
// It is only considered a retry if the task was actually executed.
if errors.Is(oldTr.Error, ErrNoPeers) {
// TODO Should we sleep a bit to wait for peers?
} else {
if !errors.Is(oldTr.Error, ErrNoPeers) {
if errors.Is(oldTr.Error, io.EOF) || errors.Is(oldTr.Error, network.ErrStreamReset) {
w.removePeer(oldTr.Who)
logger.Debugf("removed peer %s from the worker pool", oldTr.Who)
}

tr.Retries = oldTr.Retries + 1
tr.Completed = w.maxRetries != UnlimitedRetries && tr.Retries >= w.maxRetries
}
Expand Down

0 comments on commit 3accdcb

Please sign in to comment.