-
-
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
HttpToHttp2ConnectionHandler#write continues on error and doesn't report correct exception #11161
Comments
@Scottmitch May I ask some guidance regarding this issue, please? In 6a2425b#diff-7658fbccab9a300ae85f5d2f17d9469419e4af5d04c9ba12058f1fc418ff99b5, you introduced this behavior This leads here to cascading failures while interrupting is the desired behavior and to the wrong Exception being reported. |
The
Some areas make a best effort up-front check if the promise is already completed (e.g.
I think we should preserve (1) (e.g. passing a promise to an API transfers ownership, don't rely upon that API to double-check), and the lowest impact change would be to modify |
Motivation: SimpleChannelPromiseAggregator implements the promise API and allows for multiple operations to share a common promise. It currently propagates the last exception to occur, but this may mask the original exception which lead to the last exception and make debugging more difficult. Modifications: - SimpleChannelPromiseAggregator propagates the first exception instead of the last exception. Result: Fixes netty#11161.
@slandelle - please check #11168 for the proposed fix. |
@Scottmitch Thanks a lot, I'll have a look this afternoon. However, is changing SimpleChannelPromiseAggregator enough?
It also feels suspicious that the ChannelFutures returned by |
This change is sufficient to preserve the first/"original" exception.
You are correct if one operation fails the, subsequent operations are also expected to fail. As described above in (2) a goal was to simplify the control flow and improve readability (assuming exceptions are "exceptional"). This code could be re-written to break out early with more branches/conditionals but you would have to be careful to ensure resources are released (e.g.
A common pattern in Netty is as follows: ChannelFuture doWork(...) {
// allocates a ChannelPromise internally, returns the ChannelFuture to listen for results
return doWork(..., newPromise());
}
ChannelFuture doWork(..., ChannelPromise p) {
// do the work, complete p when done
return p;
} With this pattern if you provide your own |
…11168) Motivation: SimpleChannelPromiseAggregator implements the promise API and allows for multiple operations to share a common promise. It currently propagates the last exception to occur, but this may mask the original exception which lead to the last exception and make debugging more difficult. Modifications: - SimpleChannelPromiseAggregator propagates the first exception instead of the last exception. Result: Fixes #11161.
@slandelle please reopen if you think there is more work todo |
…11168) Motivation: SimpleChannelPromiseAggregator implements the promise API and allows for multiple operations to share a common promise. It currently propagates the last exception to occur, but this may mask the original exception which lead to the last exception and make debugging more difficult. Modifications: - SimpleChannelPromiseAggregator propagates the first exception instead of the last exception. Result: Fixes #11161.
…etty#11168) Motivation: SimpleChannelPromiseAggregator implements the promise API and allows for multiple operations to share a common promise. It currently propagates the last exception to occur, but this may mask the original exception which lead to the last exception and make debugging more difficult. Modifications: - SimpleChannelPromiseAggregator propagates the first exception instead of the last exception. Result: Fixes netty#11161.
Expected behavior
HttpToHttp2ConnectionHandler#write should interrupt as soon as an Exception occurs and should report it.
This looks similar to what was reported in #6705.
Actual behavior
When an Exception occurs, it's recorded in a
SimpleChannelPromiseAggregator
.The execution continues, eg if the Exception occurred in
writeHeaders
,writeData
will be performed, typically resulting in cascading failures such as "stream is missing".SimpleChannelPromiseAggregator
only reports the last Exception, losing the actual and useful one.Steps to reproduce
Try to write a FullHttpRequest with a stream id that exceeds the max number of concurrent stream.
DefaultHttpConnection#checkNewStreamAllowed
will throw an Http2Exception("Maximum active streams violated for this endpoint.")DefaultHttp2ConnectionEncoder#writeHeaders0
will catch it and fail the promiseHttpToHttp2ConnectionHandler
will proceed withwriteData
DefaultHttp2ConnectionEncoder#writeData
will crash inrequireStream
with an IllegalArgumentException("Stream no longer exists"), catch it and fail the promise, replacing the original ExceptionMinimal yet complete reproducer code (or URL to code)
Netty version
4.1.63
JVM version (e.g.
java -version
)irrelevant
OS version (e.g.
uname -a
)irrelevant
The text was updated successfully, but these errors were encountered: