Repository navigation
[client-v2] Fix compressed buffer size for incompressible request data - #3303
Merged
Merged
Conversation
chernser
approved these changes
Nov 5, 2026
Contributor
|
Thank you for the fix! Seems we need to port it to |
1 task done
chernser
pushed a commit
that referenced
this pull request
Nov 5, 2026
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.
Summary
CompressedBlockOutputStreamsized its output buffer asbufferSize + HEADER_LENGTH, so the compressor had no room for blocks that grow when compressed (e.g. random data). Since 0342bd9, this made LZ4 and ZSTD request compression fail with "maxDestLen is too small" / "Destination buffer is too small". The buffer is now sized with each codec's worst-case bound:LZ4Compressor.maxCompressedLengthandZstd.compressBound.Added
CompressedBlockOutputStreamTest, which round-trips full 64 KiB blocks of incompressible and compressible data through both codecs.Closes #3302
Checklist
Note
Low Risk
Localized buffer sizing fix in client compression with new unit tests; public stream constructors are unchanged.
Overview
Fixes request compression failures when a full block does not shrink under LZ4/ZSTD (e.g. random payload data).
CompressedBlockOutputStreampreviously allocated the destination buffer as large as the uncompressed block, which is too small when compression expands data and triggered errors like maxDestLen is too small / Destination buffer is too small.The base constructor now takes a separate
maxCompressedBufferSize, and LZ4 / ZSTD wrappers set it viaLZ4Compressor.maxCompressedLength(bufferSize)andZstd.compressBound(bufferSize)respectively. Uncompressed chunk size is unchanged.Adds
CompressedBlockOutputStreamTestwith 64 KiB round-trip cases for both codecs on incompressible and compressible payloads.Reviewed by Cursor Bugbot for commit 81ab6b1. Bugbot is set up for automated code reviews on this repo. Configure here.