netsync: clear ibdMode when the sync peer is dropped #2690
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.39) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.39 · 252 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.331
Real PR Conversation Timeline
1 comments
"Review active on #2690"
general
weight: 0.35
allocz
In this PR, we fix a state leak in the sync manager that could leave a node permanently stuck behind the chain tip while connected to healthy peers.
Problem
ibdModeis set whenstartSyncpicks a sync peer, but it was only cleared when the final block of a download arrived. When the sync peer stalled or disconnected,updateSyncPeersetsyncPeerto nil and calledstartSync. If no remaining peer advertised a height above ours (or the chain was already current),startSyncreturned without selecting a peer, and without touchingibdMode.That left
ibdModeset with no sync peer, which is a dead end:handleInvMsgskips every announcement whileibdModeis set, so no new block is ever requested.fetchHigherPeersstays empty.startSyncagain.A node in this state sits idle until it happens to connect to a new peer. I hit this on an outbound-only node (
--nolisten, 8 peers): a goroutine dump showedblockHandlerparked in itsselect, every peer sitting in a normal read, and no peer churn for ~16 hours, while the node was well behind the tip.Fix
Clear
ibdModewheresyncPeeris cleared, soibdModecan only be on while a sync peer is driving the download (ibdModeimpliessyncPeer != nil).startSyncsets it again when it selects a replacement. Once cleared, announcements are processed again and a lagging node catches up through the usual orphan/getblockspath.TestIBDModeClearedWithoutSyncPeercovers both ways the sync peer goes away (stall sampler, disconnect), and fails without the change.Not covered
A sync peer that keeps replying to
getheaderswith headers we already have resetslastProgressTimeon every reply (handleHeadersMsg), so the stall sampler never fires even though our best header isn't advancing. That is a separate, pre-existing way to get a similar frozen state. It needs an unusual peer or fork, so I've left it for a follow-up.