Describe the issue
I need to investigate a bit more, but I just completed a fresh sync from scratch using master, and I noticed some odd behavior with the stalling logic.
I was initially connected to 8 outbound peers (and no others), and then to speed up the sync, I decided to addnode an instance on my local network that was caught up. So in particular, block transfer times to this new node were very quick.
What was unusual was that even though this machine fast, it was getting disconnected repeatedly during IBD for stalling (it would then get readded, since addnode’d it). I started to look through my debug log to see what was going on, and it appears to me that it may have been something like this:
- Some other peer X is stalling, gets disconnected.
- Connect to some new peer Y.
- X’s blocks get assigned to other peers, maybe the local one.
- If we’re near the end of the download window, then because Y is available not downloading any blocks, the peer that was reassigned X’s block has 1 second (?) to provide the block, or else that peer is stalling.
So it looked to me like I’d go through periods of time where everyone was getting disconnected for stalling, such as this particularly egregious example:
02016-11-22 13:08:52 UpdateTip: new best=00000000000000003085d45701cef706396618d68bea4b9551b7442b031d1863 height=313019 version=0x00000002 log2_work=79.946856 tx=43453816 date='2014-07-29 15:40:42' progress=0.218633 cache
1=1581.8MiB(3793192tx)
22016-11-22 13:08:54 Peer=290 is stalling block download, disconnecting
32016-11-22 13:08:56 Peer=282 is stalling block download, disconnecting
42016-11-22 13:08:58 Peer=291 is stalling block download, disconnecting
52016-11-22 13:09:06 Peer=292 is stalling block download, disconnecting
62016-11-22 13:09:08 Peer=286 is stalling block download, disconnecting
72016-11-22 13:09:11 Peer=293 is stalling block download, disconnecting
82016-11-22 13:09:15 Peer=294 is stalling block download, disconnecting
92016-11-22 13:09:17 Peer=295 is stalling block download, disconnecting
102016-11-22 13:09:19 Peer=296 is stalling block download, disconnecting
112016-11-22 13:09:21 Peer=297 is stalling block download, disconnecting
122016-11-22 13:09:23 Peer=298 is stalling block download, disconnecting
132016-11-22 13:09:28 Peer=299 is stalling block download, disconnecting
142016-11-22 13:09:30 Peer=300 is stalling block download, disconnecting
152016-11-22 13:09:32 Peer=301 is stalling block download, disconnecting
162016-11-22 13:09:35 Peer=302 is stalling block download, disconnecting
172016-11-22 13:09:37 Peer=303 is stalling block download, disconnecting
182016-11-22 13:09:39 Peer=304 is stalling block download, disconnecting
192016-11-22 13:09:41 Peer=305 is stalling block download, disconnecting
202016-11-22 13:09:43 Peer=306 is stalling block download, disconnecting
212016-11-22 13:09:45 Peer=307 is stalling block download, disconnecting
222016-11-22 13:09:48 Peer=309 is stalling block download, disconnecting
232016-11-22 13:09:51 Peer=310 is stalling block download, disconnecting
242016-11-22 13:09:53 Peer=311 is stalling block download, disconnecting
252016-11-22 13:09:55 Peer=312 is stalling block download, disconnecting
262016-11-22 13:09:57 Peer=313 is stalling block download, disconnecting
272016-11-22 13:09:59 UpdateTip: new best=00000000000000001291028bceab2639c12c762be3988017cba99fa792b460c4 height=313020 version=0x00000002 log2_work=79.946955 tx=43454953 date='2014-07-29 15:45:18' progress=0.218647 cache=1581.8MiB(3793020tx)
EDIT: forgot to mention that the above snippet is from me grepping for “stalling|UpdateTip” in my debug.log, so the new connections that happened in between those stalling messages aren’t shown.