fix(http2): pooled connection wedges under concurrent load#843
Merged
fix(http2): pooled connection wedges under concurrent load#843
Conversation
…ency Fixes #836. The pool checks out TCP then upgrades to SSL+ALPN, so connected(enter) armed the 2s idle timer while still classified as http1; the timer fired on a busy H2 conn and tore it down mid-request. Cancel the timer in init_h2_{connection,after_upgrade}, trap EXIT from h2_connection, keep hackney_conn alive briefly in `closed` so late racing calls get an error reply, validate state on checkout_h2, and bump h2 to 0.4.0. Adds a regression test.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix for #836.
The pool takes a TCP connection first, then upgrades it with SSL + ALPN. But
connected(enter)runs before ALPN, so at this moment the protocol is still http1 and the 2s pool idle timer gets armed. On a busy multiplexed H2 connection this timer fires and closes it in the middle of a request; the in-flightgen_statem:callraisesexit:{normal, _}and the caller thinks it hangs.We cancel the idle timer on h2 upgrade (the h2 lib manages its own keepalive), trap EXIT from the linked
h2_connection, and keephackney_connalive 50ms inclosedso late racing calls get a proper error.checkout_h2also checks the process state, not onlyis_process_alive. Bump h2 to 0.4.0 + regression test.Reproducer from #836 now finishes properly, 810 eunit tests pass.