Skip to content

Commit 3536a64

Browse files
committed
DF-23489 multinode: short-circuit recovery polling on 0 PollInterval
1 parent e83ad43 commit 3536a64

2 files changed

Lines changed: 31 additions & 2 deletions

File tree

multinode/node_lifecycle.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,10 +532,10 @@ func (n *node[CHAIN_ID, HEAD, RPC]) outOfSyncLoop(syncIssues syncStatus) {
532532
// When threshold is 0 the probe is disabled and the function returns true immediately.
533533
func (n *node[CHAIN_ID, HEAD, RPC]) probeUntilStable(ctx context.Context, lggr logger.Logger) bool {
534534
threshold := n.nodePoolCfg.PollSuccessThreshold()
535-
if threshold == 0 {
535+
pollInterval := n.nodePoolCfg.PollInterval()
536+
if threshold == 0 || pollInterval <= 0 {
536537
return true
537538
}
538-
pollInterval := n.nodePoolCfg.PollInterval()
539539
var successes uint32
540540
for successes < threshold {
541541
select {

multinode/node_lifecycle_test.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,6 +1583,35 @@ func TestUnit_NodeLifecycle_unreachableLoop(t *testing.T) {
15831583
func TestUnit_NodeLifecycle_probeUntilStable(t *testing.T) {
15841584
t.Parallel()
15851585

1586+
t.Run("returns true immediately when pollInterval is zero, skipping probe", func(t *testing.T) {
1587+
t.Parallel()
1588+
rpc := newMockRPCClient[ID, Head](t)
1589+
// ClientVersion is intentionally NOT mocked: if the guard is missing the loop fires
1590+
// immediately (time.After(0)) and calls ClientVersion, which makes the test fail.
1591+
node := newTestNode(t, testNodeOpts{
1592+
rpc: rpc,
1593+
config: testNodeConfig{
1594+
pollSuccessThreshold: 2,
1595+
pollInterval: 0,
1596+
},
1597+
})
1598+
result := node.probeUntilStable(t.Context(), logger.Test(t))
1599+
assert.True(t, result)
1600+
})
1601+
t.Run("returns true immediately when pollInterval is negative, skipping probe", func(t *testing.T) {
1602+
t.Parallel()
1603+
rpc := newMockRPCClient[ID, Head](t)
1604+
// ClientVersion is intentionally NOT mocked: same reasoning as above.
1605+
node := newTestNode(t, testNodeOpts{
1606+
rpc: rpc,
1607+
config: testNodeConfig{
1608+
pollSuccessThreshold: 2,
1609+
pollInterval: -1,
1610+
},
1611+
})
1612+
result := node.probeUntilStable(t.Context(), logger.Test(t))
1613+
assert.True(t, result)
1614+
})
15861615
t.Run("returns true immediately when threshold is zero, skipping probe", func(t *testing.T) {
15871616
t.Parallel()
15881617
rpc := newMockRPCClient[ID, Head](t)

0 commit comments

Comments
 (0)