Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v23.2.x] compression: Allocate memory for LZ4_compressEnd #17160

Conversation

vbotbuildovich
Copy link
Collaborator

Backport of PR #17156

Before this change the code assumed that the destination temp. buffer
always had enough free space for LZ4F_compressEnd operation. This change
checks the free size before calling LZ4F_compressEnd and allocates a new
buffer if necessary.

Note that the free space required is computed using LZ4F_compressBound
with a srcSize of 0. By looking at LZ4F_compressEnd it may appear that
we can just check if 12 bytes are free in the destination buffer, whereas
LZ4F_compressBound always assumes at least 65443 ie 65535 + block header
size (4) + frame footer (4).

However, lz4frame docstring for LZ4F_compressBound states that:

"When srcSize==0, LZ4F_compressBound() provides an upper bound for
LZ4F_flush() and LZ4F_compressEnd() instead."

Similar directions are mentioned on LZ4 gh issues, so it is safer to be
conservative and possibly allocate the extra bytes.

(cherry picked from commit 1493c6d)
@vbotbuildovich vbotbuildovich added this to the v23.2.x-next milestone Mar 18, 2024
@vbotbuildovich vbotbuildovich added the kind/backport PRs targeting a stable branch label Mar 18, 2024
@vbotbuildovich vbotbuildovich requested a review from abhijat March 18, 2024 11:26
@piyushredpanda
Copy link
Contributor

CI failure: #8217

@piyushredpanda piyushredpanda merged commit 17b9b59 into redpanda-data:v23.2.x Mar 18, 2024
20 of 23 checks passed
@piyushredpanda piyushredpanda modified the milestones: v23.2.x-next, v23.2.28 Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/redpanda kind/backport PRs targeting a stable branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants