Skip to content

Commit

Permalink
Merge pull request #3901 from oasisprotocol/kostko/stable/21.1.x/back…
Browse files Browse the repository at this point in the history
…port-multi-2

[BACKPORT/21.1.x] Minor runtime worker fixes
  • Loading branch information
kostko authored Apr 29, 2021
2 parents efadf65 + 6a9abc1 commit fd95ee7
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
7 changes: 7 additions & 0 deletions .changelog/3889.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Runtime workers should wait for history reindex

If a node first syncs consensus without any runtimes configured and a runtime
is configured later, the workers should wait for historic runtime block
reindexing to complete before continuing with initialization. Otherwise
historic block queries may fail and prevent the worker from operating
normally.
1 change: 1 addition & 0 deletions .changelog/3899.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
worker/storage: Fix heartbeat stall
11 changes: 8 additions & 3 deletions go/worker/common/committee/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,9 +413,7 @@ func (n *Node) worker() {
}
defer nodeUpsSub.Close()

// We are initialized.
close(n.initCh)

initialized := false
for {
select {
case <-n.stopCh:
Expand All @@ -431,6 +429,13 @@ func (n *Node) worker() {
n.Height = blk.Height
}()
case blk := <-blocks:
// We are initialized after we have received the first block. This makes sure that any
// history reindexing has been completed.
if !initialized {
close(n.initCh)
initialized = true
}

// Received a block (annotated).
func() {
n.CrossNode.Lock()
Expand Down
5 changes: 5 additions & 0 deletions go/worker/storage/committee/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,10 @@ func (h *heartbeat) reset() {

boff := backoff.NewExponentialBackOff()
boff.InitialInterval = 5 * time.Second
boff.MaxElapsedTime = 0
boff.MaxInterval = 20 * time.Second
h.Ticker = backoff.NewTicker(boff)

// Gobble the first tick, which is immediate.
<-h.C
}

0 comments on commit fd95ee7

Please sign in to comment.