-
-
Notifications
You must be signed in to change notification settings - Fork 15.8k
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
rational for fireExceptionCaught when an IOException will close the connection anyways #4930
Comments
@trustin @normanmaurer @nmittler @ejona86 - WDYT? |
For gRPC we need to know why the channel was closed. Even with the current state, it is very easy to lose the shutdown reason and only have Just failing the futures doesn't work well because there are so many places writes are performed and it is inefficient.
I'm fairly okay with the current behavior, except for the logspam. I'd rather see no processing of the future used with goaway or it log at the debug level instead of error/warn. Granted, we've not been running with some of the recent changes, so maybe this is no longer a problem. In general I don't care if GOAWAY fails. The only time I do is if
I don't know what indicator that would be. Keeping state could maybe work, although I do think it may have a good number of problems, like exceptionCaught doesn't mean the connection will be closed since it could possibly be handled gracefully. |
Thanks for the feedback @ejona86. Agreed I think keeping the current
We still need to process the future to close the channel in the happy path case. However reducing the log level to debug seems like a good approach in this situation. Since I broke this let me submit a PR. |
Motivation: netty@83c4aa6 changed the log level to warn, but should have changed to debug. Modifications: - Change the log level to debug in Http2ConnectionHandler if the GO_AWAY fails to send. The write failure could be the result of the channel already being closed. Result: Fixes netty#4930.
To avoid letting exceptions flow through to the end of the pipeline and go unhanded one approach is to insert an inbound channel handler to the end of the pipeline which simply closes the connection if any unexpected exceptions are caught. In the case of the codec-http2 there is some logic which must be done when a channel is closed (send GO_AWAY and graceful shutdown). codec-http2 attempts to distinguish if the GO_AWAY should be attempted based upon the state of the channel, and will not attempt a GO_AWAY if the channel is not active [1].
Currently if while reading we catch an exception we call
fireExceptionCaught
and then close the channel [2]. When this happens the last channel inbound handler catches the unexpected exception and callsctx.close()
. codec-http2's close method is now called, but the state of the channel is still active and thus the GO_AWAY logic executed, but the send fails and logs a warning.The question is what is the correct way to handle this situation?
fireExceptionCaught
in cases where the connection will be closed?instanceof IOException
... this feels risky)[1] https://github.com/netty/netty/blob/4.1/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2ConnectionHandler.java#L414
[2] https://github.com/netty/netty/blob/4.1/transport/src/main/java/io/netty/channel/nio/AbstractNioByteChannel.java#L87
The text was updated successfully, but these errors were encountered: