Skip to content

Gracefully handle GOAWAY #1479

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

Merged
merged 3 commits into from
Oct 21, 2019
Merged

Gracefully handle GOAWAY #1479

merged 3 commits into from
Oct 21, 2019

Conversation

dagnir
Copy link
Contributor

@dagnir dagnir commented Oct 18, 2019

Description

  • Ensure that the GOAWAY exception is fired within each child channel's event
    loop to ensure correct ordering

  • Fix off-by-one error in MultiplexedChannelRecord

  • Add tests using a minimal H2 endpoint implementation

  • Remove test-server module since it's no longer needed

Motivation and Context

Bug fix.

Testing

  • New unit tests
  • Integration tests
  • Will run stability tests

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read the CONTRIBUTING document
  • Local run of mvn install succeeds
  • My code follows the code style of this project
  • My change requires a change to the Javadoc documentation
  • I have updated the Javadoc documentation accordingly
  • I have read the README document
  • I have added tests to cover my changes
  • All new and existing tests passed
  • A short description of the change has been added to the CHANGELOG
  • My change is to implement 1.11 parity feature and I have updated LaunchChangelog

License

  • I confirm that this pull request can be released under the Apache 2 license

@dagnir dagnir changed the title Dongie/respect goaway fix Gracefully handle GOAWAY Oct 18, 2019
@codecov-io
Copy link

codecov-io commented Oct 19, 2019

Codecov Report

Merging #1479 into master will increase coverage by 0.61%.
The diff coverage is 66.66%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #1479      +/-   ##
============================================
+ Coverage     73.81%   74.43%   +0.61%     
  Complexity      720      720              
============================================
  Files           850      852       +2     
  Lines         26160    26175      +15     
  Branches       2018     2018              
============================================
+ Hits          19311    19483     +172     
+ Misses         5974     5803     -171     
- Partials        875      889      +14
Flag Coverage Δ Complexity Δ
#unittests 74.43% <66.66%> (+0.61%) 720 <0> (ø) ⬇️
Impacted Files Coverage Δ Complexity Δ
...etty/internal/http2/Http2ToHttpInboundAdapter.java 56.52% <ø> (+56.52%) 0 <0> (ø) ⬇️
.../netty/internal/http2/Http2GoAwayFrameHandler.java 100% <100%> (ø) 0 <0> (?)
...nio/netty/internal/ChannelPipelineInitializer.java 97.72% <100%> (+25.63%) 0 <0> (ø) ⬇️
...netty/internal/http2/MultiplexedChannelRecord.java 66.66% <56%> (+51.28%) 0 <0> (ø) ⬇️
...http/nio/netty/internal/http2/GoAwayException.java 80% <80%> (ø) 0 <0> (?)
...wssdk/http/nio/netty/internal/ResponseHandler.java 88.38% <0%> (+1.29%) 0% <0%> (ø) ⬇️
...awssdk/http/nio/netty/NettyNioAsyncHttpClient.java 67.44% <0%> (+1.55%) 0% <0%> (ø) ⬇️
.../http/nio/netty/internal/NettyRequestExecutor.java 65.42% <0%> (+1.59%) 0% <0%> (ø) ⬇️
... and 13 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 55e7e93...5acb3e0. Read the comment docs.

endpointDriver.channels.forEach(ch -> endpointDriver.goAway(ch, 1));

// Need to give a chance for the streams to get closed
Thread.sleep(1000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have we run this enough to be convinced it isn't flaky?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1s is a pretty long time to close 2 connections so it should be fine

Comment on lines +121 to +133
if (streamId == 3) {
stream3Received.complete(null);
}

if (streamId < 5) {
Http2Headers outboundHeaders = new DefaultHttp2Headers()
.status("200")
.add("content-type", "text/plain")
.addInt("content-length", getPayload.length);

frameWriter().writeHeaders(ctx, streamId, outboundHeaders, 0, false, ctx.newPromise());
ctx.flush();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm probably missing something. Why 3 and 5 when there's only 2 requests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The client always initiates streams using odd numbers. The first stream used to establish the H2 stream is 1, so the next two are 3 and 5.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, cool!

@@ -62,7 +74,7 @@ public void closeWaitsForConnectionToBeReleasedBeforeClosingConnectionPool() thr
Promise<Void> releasePromise = Mockito.spy(new DefaultPromise<>(loopGroup.next()));
Mockito.doCallRealMethod().when(releasePromise).await();
releasePromise.setSuccess(null);
Mockito.when(connectionPool.release(Mockito.eq(channel))).thenReturn(releasePromise);
Mockito.when(connectionPool.release(eq(channel))).thenReturn(releasePromise);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this file, still?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can revert this

 - Ensure that the GOAWAY exception is fired within each child channel's event
   loop to ensure correct ordering

 - Fix off-by-one error in MultiplexedChannelRecord

 - Add tests using a minimal H2 endpoint implementation

 - Remove test-server module since it's no longer needed
@dagnir dagnir force-pushed the dongie/respect-goaway-fix branch from 5acb3e0 to 4e4c411 Compare October 21, 2019 17:34
Comment on lines +121 to +133
if (streamId == 3) {
stream3Received.complete(null);
}

if (streamId < 5) {
Http2Headers outboundHeaders = new DefaultHttp2Headers()
.status("200")
.add("content-type", "text/plain")
.addInt("content-length", getPayload.length);

frameWriter().writeHeaders(ctx, streamId, outboundHeaders, 0, false, ctx.newPromise());
ctx.flush();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, cool!

@dagnir dagnir merged commit f961f29 into master Oct 21, 2019
@dagnir dagnir deleted the dongie/respect-goaway-fix branch March 17, 2020 23:57
aws-sdk-java-automation added a commit that referenced this pull request Jun 17, 2021
…7dad42406

Pull request: release <- staging/285aae68-af2e-4c5c-a25a-81d7dad42406
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants