GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — FlowControlHandler: don't drop outstanding reads on channelReadComplete by hachen-r7 · Pull Request #18472 · netty/netty

Conversation

@hachen-r7

@hachen-r7 hachen-r7 commented Nov 18, 2026

Copy link
Copy Markdown

Motivation:

Since 4.1.136, FlowControlHandler resets its count of unsatisfied downstream read() calls in channelReadComplete. With auto-read disabled, this can stall a channel forever:

  • A downstream handler that calls read() while processing the last message of a read cycle loses that read. The HTTP relay from FlowControlHandler: relay stalls from 4.1.136.Final when auto-read is disabled per the documented pattern #17628 stalls after 34,750 of 1,048,576 bytes.
  • An upstream read cycle can produce no message for this handler, for example because a decoder in front of it received only a partial frame, or because of a zero-byte NIO read. That cycle still consumes every outstanding read, while the transport keeps reading, so the next message stays queued and is never delivered.

Modification:

  • Stop resetting unsatisfiedReads in channelReadComplete. A read() is now satisfied only by delivering a message. This matches the class javadoc ("only one message per read()") and restores the 4.1.135 behaviour, where shouldConsume also survived channelReadComplete. The unsatisfiedReads javadoc is updated to match.
  • Add regression tests:
    • testReadIssuedAfterMessageSurvivesSameReadComplete
    • testReadSurvivesUpstreamCycleWithoutMessage
    • testReadInChannelReadSurvivesFrameSplitAcrossReads
    • HttpServerCodecFlowControlTest, a socket-based HTTP relay that mirrors the FlowControlHandler: relay stalls from 4.1.136.Final when auto-read is disabled per the documented pattern #17628 reproducer
  • Update the last block of testMultipleReadsOnEmptyQueue. It asserted that a message is not delivered after an empty read cycle, which is the stall itself.

Result:

Fixes #17628.

All five new or changed tests fail without the change in FlowControlHandler; the relay test stalls at exactly 34,750 bytes. With the change, these pass locally: FlowControlHandlerTest (24/24), HttpServerCodecFlowControlTest, HttpContentDecompressorTest (the #16837 reproducer), HttpServerCodecTest and HttpObjectAggregatorTest.

One point for reviewers: outstanding reads are now preserved across empty upstream cycles, so N read() calls yield N messages. In 4.1.135, a single boolean flag effectively capped this at one pending read. See also the discussion in #17046.

Credit and relation to #17647:

This supersedes #17647 by @Asthenia0412, which has been stalled on a failing CI build for over a month. A follow-up patch posted there a week ago got no response. This PR is #17647 squashed onto the current 4.1, plus that patch:

  • The fix and the tests come from FlowControlHandler: preserve reads requested during a read cycle #17647. Its authors are credited as Co-authored-by on the commit.
  • @allthingssecurity's review on #17647 identified the empty-cycle stall, proposed the one-line fix in channelReadComplete, and wrote two of the regression tests.
  • The new parts are making HttpServerCodecFlowControlTest compile with -source 1.6, which is why verify-pr failed on FlowControlHandler: preserve reads requested during a read cycle #17647, and removing the two fields that were left unused after FlowControlHandler: preserve reads requested during a read cycle #17647's second commit.

I'm happy to close this in favour of #17647 if its author picks it up again.

🤖 Generated with Claude Code

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@hachen-r7 @Asthenia0412
yancy @claude
FlowControlHandler: don't drop outstanding reads on channelReadComplete
f1ebbce
Motivation:

Since 4.1.136, FlowControlHandler resets its count of unsatisfied
downstream read() calls when the upstream read cycle completes. With
auto-read disabled this can stall the channel forever:

- a downstream handler that calls read() while processing the last
  message of a read cycle loses that read (HTTP relay in netty#17628 stalls
  after ~34 KB of a 1 MiB body);
- an upstream read cycle that produces no message for this handler
  (e.g. a decoder in front of it got only a partial frame, or a
  zero-byte NIO read) consumes every outstanding read, while the
  transport keeps reading and the next message is queued forever.

Modification:

- Keep outstanding reads across upstream channelReadComplete. A read()
  is now only satisfied by delivering a message, which restores the
  4.1.135 behaviour and matches the class javadoc.
- Make HttpServerCodecFlowControlTest compile with -source 1.6.
- Add regression tests for re-entrant reads, empty read cycles and
  frames split across reads; adjust testMultipleReadsOnEmptyQueue, whose
  last block asserted the stall.

Result:

Fixes netty#17628. Supersedes netty#17647 (picks up its fix, tests and review
feedback).

Co-authored-by: Stochastic <[email protected]>
Co-authored-by: yancy <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@hachen-r7 hachen-r7 mentioned this pull request Nov 18, 2026
FlowControlHandler: preserve reads requested during a read cycle #17647
Open
@testlens-app

testlens-app Bot commented Nov 23, 2026

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: f1ebbce
▶️ Tests: 204142 executed
⚪️ Checks: 18/18 completed


Learn more about TestLens at testlens.app/docs.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@hachen-r7
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.