Skip to content

Commit

Permalink
Merge pull request #4404 from oasisprotocol/tjanez/runtime-storage-sy…
Browse files Browse the repository at this point in the history
…nc-issues-backport

[BACKPORT/21.3.x] go/worker/storage: Limit number of rounds to fetch before applying them
  • Loading branch information
tjanez authored Dec 16, 2021
2 parents 1763718 + 4615b45 commit 5d5693f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .changelog/4403.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
go/worker/storage: Limit number of rounds to fetch before applying them

Previously, when a node was syncing from genesis, it would try to fetch all
unapplied rounds before applying them.
This could mean trying to fetch 100k+ rounds before applying them.
In combination with failing to fetch rounds and random retrying, this could
make the syncing process unbearably slow.
8 changes: 8 additions & 0 deletions go/worker/storage/committee/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ const (
// Trying to wait for rounds further in the future will return an error immediately.
roundWaitConsensusOffset = uint64(1)

// maxInFlightRounds is the maximum number of rounds that should be fetched before waiting
// for them to be applied.
maxInFlightRounds = 100

// getDiffTimeout is the timeout for fetching a diff from a node.
getDiffTimeout = 15 * time.Second
)
Expand Down Expand Up @@ -1243,6 +1247,10 @@ func (n *Node) worker() { // nolint: gocyclo
}

if !ok {
if len(syncingRounds) >= maxInFlightRounds {
break
}

syncing = &inFlight{
awaitingRetry: outstandingMaskFull,
}
Expand Down

0 comments on commit 5d5693f

Please sign in to comment.