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

[fix][ml] Fix memory leaks in ManagedCursorInfo and ManagedLedgerInfo decompression and compression #23960

Merged

Conversation

lhotari
Copy link
Member

@lhotari lhotari commented Feb 11, 2025

Motivation

Running ManagedCursorInfoMetadataTest and ManagedLedgerInfoMetadataTest with Netty leak detector's paranoid level reveal Netty ByteBuf leaks in ManagedCursorInfo and ManagedLedgerInfo decompression and compression.

ManagedCursorInfo compression was introduced in PIP-146. ManagedLedgerInfo compression was introduced earlier, in PR #11490.

Modifications

Fix the leak by properly releasing buffers.

  • In the parseManagedCursorInfo and parseManagedLedgerInfo methods there was a clear leak where the ByteBuf instance wasn't released
  • In the compressManagedInfo method, the CompositeByteBuf instance was never released. CompositeByteBuf might copy input buffers into a new buffer and releasing the components separately is not a correct approach. Handling exceptional cases such as decompression failing cannot be handled in the compressManagedInfo method. The compression codec implementation should handle releasing any buffers it has allocated in that case. That's why the original handling didn't even make sense.

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

@lhotari lhotari added this to the 4.1.0 milestone Feb 11, 2025
@lhotari lhotari self-assigned this Feb 11, 2025
@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Feb 11, 2025
@lhotari lhotari force-pushed the lh-fix-ml-netty-leaks-in-managed-cursor-info branch from 289c6ac to 5439c40 Compare February 11, 2025 14:30
Copy link
Member

@dao-jun dao-jun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch! LGTM

@lhotari lhotari changed the title [fix][ml] Fix memory leaks in MetaStoreImpl related to cursor info decompression and compression [fix][ml] Fix memory leaks in ManagedCursorInfo and ManagedLedgerInfo decompression and compression Feb 11, 2025
@codecov-commenter
Copy link

codecov-commenter commented Feb 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 74.29%. Comparing base (bbc6224) to head (f505789).
Report is 898 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #23960      +/-   ##
============================================
+ Coverage     73.57%   74.29%   +0.71%     
+ Complexity    32624    31926     -698     
============================================
  Files          1877     1853      -24     
  Lines        139502   143813    +4311     
  Branches      15299    16336    +1037     
============================================
+ Hits         102638   106840    +4202     
+ Misses        28908    28602     -306     
- Partials       7956     8371     +415     
Flag Coverage Δ
inttests 26.85% <0.00%> (+2.26%) ⬆️
systests 23.22% <0.00%> (-1.11%) ⬇️
unittests 73.82% <100.00%> (+0.97%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
.../apache/bookkeeper/mledger/impl/MetaStoreImpl.java 85.31% <100.00%> (-0.61%) ⬇️

... and 1039 files with indirect coverage changes

@lhotari lhotari merged commit 7f595cd into apache:master Feb 11, 2025
61 of 64 checks passed
lhotari added a commit that referenced this pull request Feb 11, 2025
… decompression and compression (#23960)

(cherry picked from commit 7f595cd)
lhotari added a commit that referenced this pull request Feb 11, 2025
… decompression and compression (#23960)

(cherry picked from commit 7f595cd)
lhotari added a commit that referenced this pull request Feb 11, 2025
… decompression and compression (#23960)

(cherry picked from commit 7f595cd)
hanmz pushed a commit to hanmz/pulsar that referenced this pull request Feb 12, 2025
nikhil-ctds pushed a commit to datastax/pulsar that referenced this pull request Feb 19, 2025
… decompression and compression (apache#23960)

(cherry picked from commit 7f595cd)
(cherry picked from commit 77dc34d)
mukesh-ctds pushed a commit to datastax/pulsar that referenced this pull request Feb 20, 2025
… decompression and compression (apache#23960)

(cherry picked from commit 7f595cd)
(cherry picked from commit 6ed9efe)
srinath-ctds pushed a commit to datastax/pulsar that referenced this pull request Feb 24, 2025
… decompression and compression (apache#23960)

(cherry picked from commit 7f595cd)
(cherry picked from commit 77dc34d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants