-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
lib/protocol: Send Close message on read error #7141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Change is probably fine, but reasoning behind is suspect. The other side is waiting in a read and closing the connection should make that read return immediately, no timeout required. |
|
The errors occur after reading the messages from the wire, i.e. the other side isn't waiting anymore thus doesn't see the closed connection. In the specific case I was looking at the error occurred on sending an index and the sender didn't notice the connection closing for quite a while. |
|
I don't understand what you mean "after reading messages from the wire". Messages are read in |
|
Ah yes, now I see: I wrote "read" in the PR title. The error in question here occurs on "dispatch". The reader loop reads the message, and if an error occurs there it will happen just as you say, but it then passes the message on to the dispatcher loop. And if an error occurs there, we close the connection, but whoever sent us the offending message is already finished sending it at that point. |
|
Right, but they should also be waiting for the next message from us in their readerLoop, and when we close the connection they should see it there? |
|
Right, and there's the actual (or an additional) problem: The protocol connection doesn't know about the underlying connection, i.e. it doesn't/can't close it. Thus an error occurring in the protocol layer doesn't close the actual connection. That could be fixed by calling I believe the changed proposed here is valuable regardless, if only to generate a more meaningful error message on the remote than just "connection closed" (or similar). |
|
Oh! So the actual TCP connection isn't closed? That's real ugly and should/must indeed be fixed, and breaks my mental model of what was going on. I'll look at this in an entirely new light then, and indeed sending the Close message isn't bad. Perhaps we should look at doing that consistently. |
|
It is when the model closes the connection, but not when the protocol closes it (which only happens on errors). |
Doing some testing for untrusted feature I noticed that errors processing cluster-config didn't result in the connection being dropped on the remote device. We are currently just closing the underlying connection in that case, not sending a BEP close-message, thus the connection first needs to time out on the remote to be noticed as closed.