Skip to content

Clear the request context when the Netty client returns a keep-alive connection to the pool - #7572

Open
morazow wants to merge 1 commit into
aws:masterfrom
morazow:netty-clear-request-context-on-release
Open

morazow wants to merge 1 commit into
aws:masterfrom
morazow:netty-clear-request-context-on-release

Conversation

@morazow

@morazow morazow commented Nov 19, 2026 •

Copy link
Copy Markdown

Motivation and Context

Fixes #7571

On native SDK benchmarking runs I did for the Apache Fluss, I found that GC cannot clear multipart uploads since they are kept in the connection. This piles up when your increase the concurrent connections and message body.

Please have a look for the more details at the issue #7571 .

Modifications

Clear the REQUEST_CONTEXT_KEY attribute on the keep-alive branch in the ResponseHandler.finalizeResponse method.

Testing

Added reproducible test file to the issue and to the PR.

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance improvement (non-breaking change which improves latency, throughput, or resource use)
  • Deprecation (marks existing functionality as deprecated)
  • Removal (removes previously deprecated functionality)
  • Documentation (changes to documentation only)

Checklist

  • I have read the CONTRIBUTING document
  • Local run of mvn install succeeds
  • My code follows the code style of this project
  • My change requires a change to the Javadoc documentation
  • I have updated the Javadoc documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed
  • I have added a changelog entry. Adding a new entry must be accomplished by running the scripts/new-change script and following the instructions. Commit the new file created by the script in .changes/next-release with your changes.
  • My change is to implement 1.11 parity feature and I have updated LaunchChangelog

AI tools

  • I wrote this pull request description myself, not with an AI tool
  • I have reviewed all changes in this pull request myself, including any generated by AI tools

License

  • I confirm that this pull request can be released under the Apache 2 license

…connection to the pool

NettyRequestExecutor stores the RequestContext of a request in the channel
attribute REQUEST_CONTEXT_KEY and nothing cleared it. An idle pooled
connection therefore kept its last request reachable, including the request
body, until the connection served another request or closed. With byte-array
bodies the client could keep up to maxConcurrency bodies on the heap after
all requests had completed.

ResponseHandler.finalizeResponse now clears the attribute in the keep-alive
branch before it releases the channel. The other release paths close the
channel, so the pool drops it together with the context.
@morazow
morazow requested a review from a team as a code owner November 19, 2026 14:33

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Netty client: idle pooled connection keeps the last request body reachable (REQUEST_CONTEXT_KEY is never cleared)

1 participant