Repository navigation
Auto-port 4.1: HTTP/2: Fix stream stall when toggling auto-read on a child channel - #17646
Merged
Merged
Conversation
…17617) Motivation: When `setAutoRead()` is called on an `Http2StreamChannel` from a different EventLoop than the one the channel is registered to (e.g., a proxy mirroring writability state between streams on different connections) we can end up not flushing the window update frame. Modification: - Ensure the window update frame is always flushed - Add unit tests Result: Fixes #17600. --------- Co-authored-by: Norman Maurer <[email protected]> (cherry picked from commit ee269f5)
🚨 All tests passed but jobs failed 🚨Failed Jobs without Test Failures❌ Build PR / linux-x86_64-java11-boringssl build 🏷️ Commit: 6b4fb23 Rerun ControlsClick the checkbox to trigger a rerun:
Learn more about TestLens at testlens.app/docs. |
lltopk
pushed a commit
to lltopk/netty
that referenced
this pull request
Oct 24, 2026
…child channel (netty#17646) Auto-port of netty#17617 to 4.1 Cherry-picked commit: ee269f5 --- Motivation: When `setAutoRead()` is called on an `Http2StreamChannel` from a different EventLoop than the one the channel is registered to (e.g., a proxy mirroring writability state between streams on different connections), a race condition can occur. This leaves the stream stalled indefinitely because the auto-read state change may be reordered against or race with read-processing on the stream channel's own EventLoop, preventing the channel from resuming reads and sending flow-control WINDOW_UPDATE frames. This issue is described in netty#17600. Modification: Modified `AbstractHttp2StreamChannel.Http2StreamChannelConfig.setAutoRead()` to ensure the auto-read state change is always applied on the channel's own EventLoop, similar to how `AUTO_STREAM_FLOW_CONTROL` is handled. The method now: 1. Checks if the channel is registered and if the current thread is on the channel's EventLoop 2. If so, applies the change immediately via `setAutoRead0()` 3. If not, schedules the change to run on the channel's EventLoop via `execute()` This ensures thread-safe, EventLoop-confined updates to the auto-read state, preventing races with concurrent read-processing. Added a comprehensive test `crossThreadSetAutoReadResumesStalledStream()` that reproduces the issue: it disables auto-read before data arrives (causing the stream to stall once the 64KiB flow-control window is exhausted), then re-enables auto-read from a foreign EventLoop. The test verifies that the stream resumes and delivers the complete response body. Result: Fixes netty#17600. Http2StreamChannel can now safely have its auto-read state toggled from any thread without risking a stalled stream. The fix maintains EventLoop-confinement for all state changes while allowing cross-thread calls to proceed safely. --------- Co-authored-by: pandareen <[email protected]> Co-authored-by: Norman Maurer <[email protected]>
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.
Auto-port of #17617 to 4.1
Cherry-picked commit: ee269f5
Motivation:
When
setAutoRead()is called on anHttp2StreamChannelfrom a different EventLoop than the one the channel is registered to (e.g., a proxy mirroring writability state between streams on different connections), a race condition can occur. This leaves the stream stalled indefinitely because the auto-read state change may be reordered against or race with read-processing on the stream channel's own EventLoop, preventing the channel from resuming reads and sending flow-control WINDOW_UPDATE frames.This issue is described in #17600.
Modification:
Modified
AbstractHttp2StreamChannel.Http2StreamChannelConfig.setAutoRead()to ensure the auto-read state change is always applied on the channel's own EventLoop, similar to howAUTO_STREAM_FLOW_CONTROLis handled. The method now:setAutoRead0()execute()This ensures thread-safe, EventLoop-confined updates to the auto-read state, preventing races with concurrent read-processing.
Added a comprehensive test
crossThreadSetAutoReadResumesStalledStream()that reproduces the issue: it disables auto-read before data arrives (causing the stream to stall once the 64KiB flow-control window is exhausted), then re-enables auto-read from a foreign EventLoop. The test verifies that the stream resumes and delivers the complete response body.Result:
Fixes #17600. Http2StreamChannel can now safely have its auto-read state toggled from any thread without risking a stalled stream. The fix maintains EventLoop-confinement for all state changes while allowing cross-thread calls to proceed safely.