Repository navigation
Fix potential CoalescingBufferQueue desync by tracking each body reader index separately - #2146
Merged
Merged
Conversation
gavinbunney
marked this pull request as ready for review
June 13, 2026 00:08
gavinbunney
requested review from
AlexanderEllis,
argha-c,
fool1280,
ilanachalom,
jguerra,
lindseyreynolds,
matthoffman and
tappenzeller
as code owners
June 13, 2026 00:08
gavinbunney
force-pushed
the
gavin/retry-refcnt
branch
from
June 13, 2026 00:30
709cdad to
2802563
Compare
…ader index separately
gavinbunney
force-pushed
the
gavin/retry-refcnt
branch
from
June 15, 2026 16:59
2802563 to
975c9c8
Compare
AlexanderEllis
approved these changes
Jun 15, 2026
AlexanderEllis
left a comment
Contributor
There was a problem hiding this comment.
Super subtle — great catch and fix!
| } | ||
|
|
||
| @Test | ||
| void bufferedBodyReplayGivesEachOriginAttemptIndependentReaderIndex() { |
gavinbunney
added a commit
that referenced
this pull request
Jul 7, 2026
https://netty.io/news/2026/07/06/4-2-16-Final.html Includes netty fix for #2146 OOM, so updated `CoalescingBufferQueueReaderIndexDesyncTest` tests to match the new behavior in the desynced queue mode.
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.
When an origin request is retried,
ProxyEndpoint.writeBufferedBodyContentreplays the same bufferedByteBufchunks to each attempt withchunk.retain(). A plainretain()shares a single reader index across every attempt, so if one attempt drains the body it advances the reader index another still-in-flight attempt's nettyCoalescingBufferQueueis pointing at.That queue can then be left reporting
readableBytes() > 0with nothing left to produce, andDefaultHttp2RemoteFlowController.writeAllocatedBytesspins emitting empty 9-byteDATAframes (frame.size()never reaches 0) into the channel outbound buffer until the heap is exhausted - netty #11959. We saw exactly this signature in a production heap dump: ~134M empty frames queued on a single channel.This switches the buffered-body replay to use
chunk.retainedDuplicate(), giving each attempt its own reader/writer index over the same memory (shared refCnt), so one attempt draining its copy can no longer move another attempt's index.Added a new
CoalescingBufferQueueReaderIndexDesyncTestto verify the mechanism against the real netty classes: the shared-index drain desyncs a realCoalescingBufferQueue, and a frame stuck in that state spins a realDefaultHttp2RemoteFlowControllerout to 200k+ empty frames - run on a separate-thread timeout with a frame cap so the spin is observable without hanging the suite.Raised netty/netty/issues/16946 and fix in netty/netty/pull/16947 to help prevent unbounded frames.