-
Notifications
You must be signed in to change notification settings - Fork 123
Fix HTTP1 to HTTP2 migration while shutdown is in progress #530
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
Fix HTTP1 to HTTP2 migration while shutdown is in progress #530
Conversation
### Motivation Calling `HTTPClient.shutdown()` may never return if connections are still starting and one new established connection results in a state migration (i.e. from HTTP1 to HTTP2 or vice versa). We forgot to migrate the shutdown state. This could result in a large dealy until `.shutdown()` returns because we wait until connections are closed because of idle timeout. Worse, it could also never return if more requests are queued because the connections would not be idle and therefore not close itself. ###Changes - Mirgrate shutdown state too - add tests for this specific case
7604763
to
54a3a68
Compare
@@ -670,6 +673,89 @@ class HTTPConnectionPool_HTTP2StateMachineTests: XCTestCase { | |||
XCTAssertTrue(queuer.isEmpty) | |||
} | |||
|
|||
func testMigrationFromHTTP1ToHTTP2WhileShuttingDown() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this test case is a little to complex... let's just focus on the thing that we actually observed.
- run request -> opens new connection (expect h1)
- shutdown pool -> queued request shall be cancelled
- connection creation is done as h2 -> connection shall be closed immediately and shutdown is done.
then we should also have this vica versa.
- run request -> opens new connection
- connection creation is done as h2 -> schedule request on h2 connection
- connection is done with the single request
- idle timeout closes h2 connection
- new request comes in. we create a new connection (expect h2)
- shutdown pool -> cancel queued request
- connection creation is done as h1 -> connection shall be closed immediately and shutdown is done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks awesome! Thanks!
6796ea0
to
8a7db19
Compare
Motivation
Calling
HTTPClient.shutdown()
may never return if connections are still starting and one new established connection results in a state migration (i.e. from HTTP1 to HTTP2 or vice versa). We forgot to migrate the shutdown state. This could result in a large delay until.shutdown()
returns because we wait until connections are closed because of idle timeout. Worse, it could also never return if more requests are queued because the connections would not be idle and therefore not close itself.Changes