Skip to content

Commit

Permalink
Fix rare TestResumption deadlock (#44821)
Browse files Browse the repository at this point in the history
  • Loading branch information
espadolini authored Jul 30, 2024
1 parent 03c0308 commit 20543ef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/resumption/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,12 @@ func runClientResumableUnlocking(ctx context.Context, resumableConn *Conn, first
case <-detached:
}

reconnectTicker.Stop()
select {
case <-reconnectTicker.Chan():
default:
}

slog.DebugContext(ctx, "connection lost, starting reconnection loop", "host_id", hostID)
reconnectDeadline := time.Now().Add(reconnectTimeout)
backoff := minBackoff
Expand Down Expand Up @@ -262,10 +268,6 @@ func runClientResumableUnlocking(ctx context.Context, resumableConn *Conn, first
}

reconnectTicker.Reset(replacementInterval)
select {
case <-reconnectTicker.Chan():
default:
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions lib/resumption/resumption_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ func testResumption(t *testing.T, network, address string, expectedHostID string
default:
}

// wait until the reconnection loop has passed the reconnection phase
// and is waiting on the reconnection timer again
clock.BlockUntil(1)
clock.Advance(replacementInterval)
redialingSyncPoint <- struct{}{}

Expand Down

0 comments on commit 20543ef

Please sign in to comment.