Skip to content
This repository has been archived by the owner on Aug 2, 2021. It is now read-only.

network: increase fetcher timeout #1979

Merged
merged 1 commit into from
Nov 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions network/stream/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"github.com/ethersphere/swarm/network"
bv "github.com/ethersphere/swarm/network/bitvector"
"github.com/ethersphere/swarm/network/stream/intervals"
"github.com/ethersphere/swarm/network/timeouts"
"github.com/ethersphere/swarm/p2p/protocols"
"github.com/ethersphere/swarm/state"
"github.com/ethersphere/swarm/storage"
Expand Down Expand Up @@ -73,8 +74,6 @@ var (
providerSetTimer = metrics.GetOrRegisterResettingTimer("network.stream.provider_set.total-time", nil)
providerNeedDataTimer = metrics.GetOrRegisterResettingTimer("network.stream.provider_need_data.total-time", nil)

activeBatchTimeout = 20 * time.Second

// Protocol spec
Spec = &protocols.Spec{
Name: "bzz-stream",
Expand Down Expand Up @@ -635,7 +634,7 @@ func (r *Registry) clientHandleOfferedHashes(ctx context.Context, p *Peer, msg *
p.Drop("error persisting interval")
return
}
case <-time.After(activeBatchTimeout):
case <-time.After(timeouts.SyncBatchTimeout):
p.logger.Error("batch has timed out", "ruid", w.ruid)
close(w.closeC) // signal the polling goroutine to terminate
p.mtx.Lock()
Expand Down Expand Up @@ -892,8 +891,6 @@ func (r *Registry) clientSealBatch(ctx context.Context, p *Peer, provider Stream
func (r *Registry) serverCollectBatch(ctx context.Context, p *Peer, provider StreamProvider, key interface{}, from, to uint64) (hashes []byte, f, t uint64, empty bool, err error) {
p.logger.Debug("serverCollectBatch", "from", from, "to", to)

const batchTimeout = 1 * time.Second

var (
batch []byte
batchSize int
Expand Down Expand Up @@ -937,12 +934,12 @@ func (r *Registry) serverCollectBatch(ctx context.Context, p *Peer, provider Str
metrics.GetOrRegisterCounter("network.stream.server_collect_batch.full-batch", nil).Inc(1)
}
if timer == nil {
timer = time.NewTimer(batchTimeout)
timer = time.NewTimer(timeouts.BatchTimeout)
} else {
if !timer.Stop() {
<-timer.C
}
timer.Reset(batchTimeout)
timer.Reset(timeouts.BatchTimeout)
}
timerC = timer.C
case <-timerC:
Expand Down
6 changes: 3 additions & 3 deletions network/timeouts/timeouts.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ var FailedPeerSkipDelay = 20 * time.Second
var FetcherGlobalTimeout = 10 * time.Second

// SearchTimeout is the max time requests wait for a peer to deliver a chunk, after which another peer is tried
var SearchTimeout = 500 * time.Millisecond
var SearchTimeout = 1500 * time.Millisecond

// SyncerClientWaitTimeout is the max time a syncer client waits for a chunk to be delivered during syncing
var SyncerClientWaitTimeout = 20 * time.Second

// Within handleOfferedHashesMsg - how long to wait for a given batch of chunks to be delivered by the peer offering them
// how long should the downstream peer wait for an open batch from the upstream peer
var SyncBatchTimeout = 10 * time.Second

// Within SwarmSyncerServer - If at least one chunk is added to the batch and no new chunks
// Within serverCollectBatch - If at least one chunk is added to the batch and no new chunks
// are added in BatchTimeout period, the batch will be returned.
var BatchTimeout = 2 * time.Second