Repository navigation
http-netty: avoid "Maximum active streams violated" after cancels on busy h2 connections - #3676
Open
bryce-anderson wants to merge 2 commits into
Open
bryce-anderson wants to merge 2 commits into
bryce-anderson wants to merge 2 commits into
Conversation
bryce-anderson
force-pushed
the
h2-counters-58fc7f35
branch
from
October 6, 2026 17:43
4fc805e to
507016c
Compare
…busy h2 connections #### Motivation An HTTP/2 client can fail requests with "Maximum active streams violated for this endpoint" when a connection is backed up, for example because the peer reads slowly. The load balancer frees a stream's concurrency slot as soon as the stream channel closes. Netty keeps counting the stream as active until its RST_STREAM, or its final DATA frame, is written, which can take as long as the socket stays full. During that time the load balancer keeps choosing the connection, Netty refuses every new stream on it, and the internal retry tries the same connection again. #### Modifications A stream's concurrency slot is now released when Netty closes the stream, so the load balancer's count can no longer fall below Netty's. - A stream that closes before sending HEADERS still releases its slot when the channel closes, because Netty never counted it. - ServiceTalk keeps its own count instead of reading Netty's. Netty creates a stream only when HEADERS are written, so it can't see requests that the load balancer has admitted but not yet sent. #### Result On a backed-up HTTP/2 connection, a cancelled or timed-out request keeps its slot until Netty closes the stream. New requests go to another connection instead of failing.
bryce-anderson
force-pushed
the
h2-counters-58fc7f35
branch
from
October 6, 2026 18:16
507016c to
6ff93cd
Compare
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.
Motivation
An HTTP/2 client can fail requests with "Maximum active streams violated for
this endpoint" when a connection is backed up, for example because the peer
reads slowly. The load balancer frees a stream's concurrency slot as soon as
the stream channel closes. Netty keeps counting the stream as active until its
RST_STREAM, or its final DATA frame, is written, which can take as long as the
socket stays full. During that time the load balancer keeps choosing the
connection, Netty refuses every new stream on it, and the internal retry
tries the same connection again.
Modifications
A stream's concurrency slot is now released when Netty closes the stream, so
the load balancer's count can no longer fall below Netty's.
channel closes, because Netty never counted it.
stream only when HEADERS are written, so it can't see requests that the load
balancer has admitted but not yet sent.
Result
On a backed-up HTTP/2 connection, a cancelled or timed-out request keeps its
slot until Netty closes the stream. New requests go to another connection
instead of failing.