Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BACKPORT/21.3.x] go/worker/storage: Limit number of rounds to fetch before applying them #4404

Merged
merged 1 commit into from
Dec 16, 2021
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
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