Skip to content

Commit

Permalink
Merge pull request #5694 from oasisprotocol/kostko/fix/rt-suspended-e…
Browse files Browse the repository at this point in the history
…pochchg

go/worker/common: Retry provisioning on epoch transitions when suspended
  • Loading branch information
kostko authored May 16, 2024
2 parents 9d157d0 + 1446c0e commit 7c21149
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
1 change: 1 addition & 0 deletions .changelog/5694.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
go/worker/common: Retry provisioning on epoch transitions when suspended
31 changes: 19 additions & 12 deletions go/worker/common/committee/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,32 +371,39 @@ func (n *Node) handleSuspendLocked(int64) {
if n.resumeCh == nil {
resumeCh := make(chan struct{})
n.resumeCh = resumeCh
rt := n.CurrentDescriptor

go func() {
epoCh, epoSub, _ := n.Consensus.Beacon().WatchEpochs(n.ctx)
defer epoSub.Close()
ch, sub, _ := n.Runtime.WatchRegistryDescriptor()
defer sub.Close()

for {
select {
case <-n.stopCh:
return
case rt := <-ch:
case <-epoCh:
// Epoch transition while suspended, maybe the version is now valid.
case rt = <-ch:
// Descriptor update while suspended.
n.CrossNode.Lock()

// Make sure we are still suspended.
if n.resumeCh == nil {
n.CrossNode.Unlock()
return
}
case <-resumeCh:
// Runtime no longer suspended, stop.
return
}

n.CurrentDescriptor = rt
n.CrossNode.Lock()

n.updateHostedRuntimeVersionLocked()
// Make sure we are still suspended.
if n.resumeCh == nil {
n.CrossNode.Unlock()
case <-resumeCh:
// Runtime no longer suspended, stop.
return
}

n.CurrentDescriptor = rt

n.updateHostedRuntimeVersionLocked()
n.CrossNode.Unlock()
}
}()
}
Expand Down

0 comments on commit 7c21149

Please sign in to comment.