Repository navigation
MultiBufferEntity add loop to produce content. - #1366
Merged
Merged
Conversation
… buffer to fix bug for http2
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The test reuses an exhausted entity, so subsequent iterations never exercise failed() with unsent staged bytes; each iteration needs a fresh entity.
1 open issue
What changed in this PR
This PR addresses #1339 by reducing small writes in multi-buffer request bodies for both REST transports, targeting bulk-request I/O overhead.
Changes:
- Loop through buffers while writes are fully accepted.
- Coalesce small buffers into a reusable 16 KiB staging buffer while preserving partial-write state.
- Add tests for coalescing, backpressure, completion, retries, and input-buffer preservation.
| File | Description |
|---|---|
java-client/src/test/java/co/elastic/clients/transport/rest5_client/MultiBufferEntityTest.java |
Adds REST5 channel and retry tests. |
java-client/src/test/java/co/elastic/clients/transport/rest_client/MultiBufferEntityTest.java |
Adds legacy encoder and retry tests. |
java-client/src/main/java/co/elastic/clients/transport/rest5_client/MultiBufferEntity.java |
Adds staged writes, looping, and pending-byte availability reporting. |
java-client/src/main/java/co/elastic/clients/transport/rest_client/MultiBufferEntity.java |
Adds staged writes and looping for the legacy transport. |
Review effort: Balanced
|
The backport to To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-8.19 8.19
# Navigate to the new working tree
cd .worktrees/backport-8.19
# Create a new branch
git switch --create backport-1366-to-8.19
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick --mainline 1 be55286f456d1f3114d5aefd6ed435dda0f25d43
# Push it to GitHub
git push --set-upstream origin backport-1366-to-8.19
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-8.19Then, create a pull request where the |
This was referenced Nov 5, 2026
Contributor
Author
|
manually packporting to 8.19 only the relevant legacy rest client part. |
l-trotta
added a commit
that referenced
this pull request
Nov 5, 2026
* keep feeding the encoder while it accepts bytes in multibuffer entity * rest5 MultiBufferEntity: coalesce small buffers into a 16 KiB staging buffer to fix bug for http2 * avoid buffering single body requests in staging buffer * better explain rest5 mbe produce * unit tests * apply same staging buffer logic to legacy rest client * rest5 MultiBufferEntityTest: use a fresh entity per retry attempt
l-trotta
added a commit
that referenced
this pull request
Nov 5, 2026
* keep feeding the encoder while it accepts bytes in multibuffer entity * rest5 MultiBufferEntity: coalesce small buffers into a 16 KiB staging buffer to fix bug for http2 * avoid buffering single body requests in staging buffer * better explain rest5 mbe produce * unit tests * apply same staging buffer logic to legacy rest client * rest5 MultiBufferEntityTest: use a fresh entity per retry attempt Co-authored-by: Laura Trotta <153528055+l-trotta@users.noreply.github.com>
l-trotta
added a commit
that referenced
this pull request
Nov 5, 2026
* keep feeding the encoder while it accepts bytes in multibuffer entity * rest5 MultiBufferEntity: coalesce small buffers into a 16 KiB staging buffer to fix bug for http2 * avoid buffering single body requests in staging buffer * better explain rest5 mbe produce * unit tests * apply same staging buffer logic to legacy rest client * rest5 MultiBufferEntityTest: use a fresh entity per retry attempt Co-authored-by: Laura Trotta <153528055+l-trotta@users.noreply.github.com>
l-trotta
added a commit
that referenced
this pull request
Nov 5, 2026
* keep feeding the encoder while it accepts bytes in multibuffer entity * rest5 MultiBufferEntity: coalesce small buffers into a 16 KiB staging buffer to fix bug for http2 * avoid buffering single body requests in staging buffer * better explain rest5 mbe produce * unit tests * apply same staging buffer logic to legacy rest client * rest5 MultiBufferEntityTest: use a fresh entity per retry attempt Co-authored-by: Laura Trotta <153528055+l-trotta@users.noreply.github.com>
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.

Fixes #1339.
MultiBufferEntity(rest5 and legacy) wrote only one buffer per output event, causing thousands of small writes per bulk request; it now keeps writing while the channel accepts data, and groups small buffers into a 16 KiB staging buffer to be sent once.