You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Summary of the conditions for the problem to occur and the outcome:
A "large" message must be being sent by both peers to each other contemporaneously (this condition can occur in some circumstances in IBD).
Where this occurs, both peers will "pause" receiving any socket buffer traffic until the full message is sent.
That message must be large enough to crash the TCP recive window on both sides (See Further Comments below).
Receiving would only be resumed when the message is sent - This condition never occurs because both sides crash the recv window before the full message can be sent (either way).
The connection at this point is inactive and effectively "hung" until the inactivity timeout kicks in and the connection is tinned.
It's entirely possible that after the connections is tinned, further/new connections have exactly the same issue (Further Comments Below).
A quick review of the Bitcoin Core 22.1.1 code base suggests that, conceptually, the problem exists there. If the relevant conditions hit, the bug should hit there, believe.
Further Comments:
"large" in this case isn't necessarily huge - depending on the network latency, TCP Windows Scaling and Windows values in play, a few hundred kilobytes should suffice.
Although the message is approximately 2Mb in Elements testing, only a few hundred kb are actually sent before the Windows are closed (see the attached tcpdump). TCP Window sizes are sub-100kb.
The application/message command line maxsendbuffer/maxrecvbuffer settings (and the related fPauseSend and fPauseRecv flags) are irrelevant to this issue - They can be set large, on both sides, and the problem will still occur. Setting them is not a workaround.
A bit of extra detail/markers:
A netstat -anp will reveal large, "stuck" Recv and Send Queues for the connection.
A tcpdump will show TCP Zero Windows on both sides of the connection - ie confirming that nothing is being pulled off the receive buffers (See attached example).
Testing simply requires hitting the conditions described above. Factors that may make the issue more likely are:
Increasing the network latency of the connection (eg using netem).
Expected behavior
The viable TCP Connection is maintained (data is read from the socket receive buffer on at least one side of the connection to relieve the stall)
Actual behavior
The connection is "stalled" until the inactivity timeout is reached, when the connection is closed (but on re-establishment with the same client, it's entirely likely the issue may recur - See to reproduce below).
To reproduce
See comments above. The issue can be difficult to reproduce. One approach using release builds is to:
Have a "client" approximately 1200 blocks behind the liquidv1 chain.
Ensure high network latency between the client and a single configured peer to sync to (eg use netem to simulate ~150ms latency)
Launch the client to proceed with IBD.
Note that this is one concrete example of the issue. The problem appears general.
System information
Tested/Reproduced on Elements versions 21.0.2 - 22.1.1
OSes = Centos 8, Unbuntu 22.0.4
Extra Information
Example debug log snippet (Elements 21.0.2 Release Build):
3388e52 Rework receive buffer pushback (Pieter Wuille)
Pull request description:
See ElementsProject/elements#1233. There, it has been observed that if both sides of a P2P connection have a significant amount of data to send, a stall can occur, where both try to drain their own send queue before trying to receive. The same issue seems to apply to the current Bitcoin Core codebase, though I don't know whether it's a frequent issue for us.
The core issue is that whenever our optimistic send fails to fully send a message, we do subsequently not even select() for receiving; if it then turns out that sending is not possible either, no progress is made at all. To address this, the solution used in this PR is to still select() for both sending and receiving when an optimistic send fails, but skip receiving if sending succeeded, and (still) doesn't fully drain the send queue.
This is a significant reduction in how aggressive the "receive pushback" mechanism is, because now it will only mildly push back while sending progress is made; if the other side stops receiving entirely, the pushback disappears. I don't think that's a serious problem though:
* We still have a pushback mechanism at the application buffer level (when the application receive buffer overflows, receiving is paused until messages in the buffer get processed; waiting on our own net_processing thread, not on the remote party).
* There are cases where the existing mechanism is too aggressive; e.g. when the send queue is non-empty, but tiny, and can be sent with a single send() call. In that case, I think we'd prefer to still receive within the same processing loop of the network thread.
ACKs for top commit:
ajtowns:
ACK 3388e52
naumenkogs:
ACK 3388e52
mzumsande:
Tested ACK 3388e52
Tree-SHA512: 28960feb3cd2ff3dfb39622510da62472612f88165ea98fc9fb844bfcb8fa3ed3633f83e7bd72bdbbbd37993ef10181b2e1b34836ebb8f0d83fd1c558921ec17
Summary of the conditions for the problem to occur and the outcome:
Further Comments:
A bit of extra detail/markers:
A
netstat -anp
will reveal large, "stuck" Recv and Send Queues for the connection.A tcpdump will show TCP Zero Windows on both sides of the connection - ie confirming that nothing is being pulled off the receive buffers (See attached example).
Testing simply requires hitting the conditions described above. Factors that may make the issue more likely are:
Expected behavior
The viable TCP Connection is maintained (data is read from the socket receive buffer on at least one side of the connection to relieve the stall)
Actual behavior
The connection is "stalled" until the inactivity timeout is reached, when the connection is closed (but on re-establishment with the same client, it's entirely likely the issue may recur - See to reproduce below).
To reproduce
See comments above. The issue can be difficult to reproduce. One approach using release builds is to:
Note that this is one concrete example of the issue. The problem appears general.
System information
Tested/Reproduced on Elements versions 21.0.2 - 22.1.1
OSes = Centos 8, Unbuntu 22.0.4
Extra Information
Example debug log snippet (Elements 21.0.2 Release Build):
The connection is "stalled" at this point,.
Example pcap file (from a different execution / on Elements 22.1.1) - Shows TCP Windows crashing each side.
ElementsTCPWindowStall.zip
The key code is GenerateSelectSet and SocketSendData.
The text was updated successfully, but these errors were encountered: