fix(http2): wait for useful send capacity before handing a chunk to h2 - #4212
Open
jeremyjpj0916 wants to merge 1 commit into
Open
jeremyjpj0916 wants to merge 1 commit into
jeremyjpj0916 wants to merge 1 commit into
Conversation
A body chunk was handed to h2 once the stream held any capacity. h2 cuts DATA frames from the capacity a stream holds, so on a connection whose window was nearly spent a chunk left as a 1-byte frame followed by more slivers. h2 0.4.16+ servers charge small non-final DATA frames to a per-connection budget and GOAWAY the connection with ENHANCE_YOUR_CALM when it runs out. Reserve min(len, 1024) instead of 1 and wait until that much is assigned. The claim stays small, so hyperium#4003 still holds, but no sub-1 KiB first frame is cut from a larger chunk. Closes hyperium#4211
2 of 6 tasks
This branch has not been deployed
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.
Closes #4211.
PipeToSendStreamhanded a polled chunk to h2 as soon as the stream held any capacity. That was usually just the 1-byte claim it reserves. h2 cuts DATA frames from whatever capacity a stream holds, so on a connection whose window was nearly used up, a 10 KB chunk went out as a 1-byte frame followed by more small frames. Since h2 0.4.16, servers charge non-final DATA frames under 256 bytes against a per-connection budget and sendGOAWAY(ENHANCE_YOUR_CALM, "too_many_data_frames")when it runs out, which fails every stream on the connection.Change
min(len, MIN_DATA_FRAME_CAPACITY)(1 KiB) for a polled chunk instead of 1 byte, and wait until that much is assigned before callingsend_data.send_data.h2_idle_stream_does_not_pin_connection_windowis unchanged.Test
h2_chunk_waits_for_useful_capacity_instead_of_sliver_frames:Without the fix the first frame is 1 byte and the test fails deterministically. With it the first frame is at least 1024 bytes.
cargo test --features fullpasses.Found while running a reverse proxy (Ferrum Edge) against a hyper backend with
adaptive_window(true), where the pooled connection was being GOAWAY'd every few seconds.