GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [fix][ml] Fix memory leak due to duplicated RangeCache value retain operations by BewareMyPower · Pull Request #23955 · apache/pulsar

Conversation

@BewareMyPower

@BewareMyPower BewareMyPower commented Feb 10, 2025

Copy link
Copy Markdown
Contributor

Motivation

#23903 introduces a memory leak issue in RangeCache#removeEntry.

-        Value value = entryWrapper.getValue(key);
+        Value value = getValueMatchingEntry(entry);

Unlike entryWrapper.getValue, getValueMatchingEntry will increase the reference count of entry's value.

Modifications

  • Remove the duplicated retain operation in RangeCache#removeEntry. Add some API notes for the private methods that might increase the reference count of the value
  • Apply the reference count validation for eviction on a RangeCache (RangeCacheTest.customTimeExtraction).

Documentation

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

Matching PR in forked repository

PR in forked repository:

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

lhotari and hezhangjian reacted with thumbs up emoji
All reactions
  • 👍 2 reactions
BewareMyPower added 2 commits February 10, 2025 21:41
@BewareMyPower
Add tests for refCnt after evinction
a1e97ca
@BewareMyPower
Fix duplicated retain operation
04a201f
@BewareMyPower BewareMyPower added type/bug The PR fixed a bug or issue reported a bug release/3.0.9 release/3.3.5 release/4.0.3 labels Feb 10, 2025
@BewareMyPower
BewareMyPower requested review from codelipenghui, heesung-sohn, lhotari, mattisonchao, poorbarcode and shibd February 10, 2025 14:03
@BewareMyPower BewareMyPower self-assigned this Feb 10, 2025
@github-actions github-actions Bot added the doc-not-needed Your PR changes do not impact docs label Feb 10, 2025
@BewareMyPower

BewareMyPower commented Feb 10, 2025

Copy link
Copy Markdown
Contributor Author

Though I think catching the IllegalReferenceCountException from value.retain() is not a good practice and error prone, let's just keep the fix simple.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@BewareMyPower BewareMyPower mentioned this pull request Feb 10, 2025
[fix][broker] Make InflightReadsLimiter asynchronous and apply it for replay queue reads #23901
Merged
1 of 4 tasks
lhotari
lhotari requested changes Feb 10, 2025
View reviewed changes

@lhotari lhotari left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thanks for finding the problem area. However, this isn't currently the correct fix to the problem. Explained in #23955 (comment) . There's also comments in the original code on line 389 and 430 where the extra reference is removed.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
lhotari
lhotari approved these changes Feb 10, 2025
View reviewed changes

@lhotari lhotari left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Oh sorry, reviewed again and noticed that it's fine.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@lhotari

lhotari commented Feb 10, 2025

Copy link
Copy Markdown
Member

The removeEntry logic could be simplified further. The logic in this method should have been improved while adding the EntryWrapper in #22814. With EntryWrapper, it's possible to remove the exact entry from the map, which wasn't possible before adding EntryWrapper.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@lhotari

lhotari commented Feb 10, 2025

Copy link
Copy Markdown
Member

Though I think catching the IllegalReferenceCountException from value.retain() is not a good practice and error prone, let's just keep the fix simple.

This is necessary in this case due to the racy usage of the cache without synchronization.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

lhotari added 2 commits February 10, 2025 17:26
@lhotari
Remove unnecessary logic which should have been removed after adding …
37b7cd6
…EntryWrapper
@lhotari
Follow up to previous commit
9a9370a
@codecov-commenter

codecov-commenter commented Feb 10, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 80.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 74.23%. Comparing base (bbc6224) to head (9a9370a).
Report is 894 commits behind head on master.

Files with missing lines Patch % Lines
...org/apache/bookkeeper/mledger/util/RangeCache.java 80.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #23955      +/-   ##
============================================
+ Coverage     73.57%   74.23%   +0.66%     
+ Complexity    32624    31919     -705     
============================================
  Files          1877     1853      -24     
  Lines        139502   143828    +4326     
  Branches      15299    16344    +1045     
============================================
+ Hits         102638   106773    +4135     
+ Misses        28908    28674     -234     
- Partials       7956     8381     +425     
Flag Coverage Δ
inttests 26.67% <53.33%> (+2.08%) ⬆️
systests 23.25% <53.33%> (-1.08%) ⬇️
unittests 73.77% <80.00%> (+0.93%) ⬆️

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

Files with missing lines Coverage Δ
...org/apache/bookkeeper/mledger/util/RangeCache.java 80.79% <80.00%> (-14.62%) ⬇️

... and 1041 files with indirect coverage changes

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@lhotari

lhotari commented Feb 10, 2025

Copy link
Copy Markdown
Member

I'll merge this as soon as it completes, since I'm creating a PR to prevent future regressions by enabling Netty Leak detector in Pulsar CI so that any detected leak will make the build fail.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@lhotari
lhotari merged commit 20b3b22 into apache:master Feb 10, 2025
@lhotari lhotari added release/3.0.10 and removed release/3.0.9 labels Feb 10, 2025
lhotari added a commit that referenced this pull request Feb 10, 2025
@BewareMyPower @lhotari
[fix][ml] Fix memory leak due to duplicated RangeCache value retain o…
dafd347
…perations (#23955)

Co-authored-by: Lari Hotari <[email protected]>
(cherry picked from commit 20b3b22)
lhotari added a commit that referenced this pull request Feb 10, 2025
@BewareMyPower @lhotari
[fix][ml] Fix memory leak due to duplicated RangeCache value retain o…
449da0a
…perations (#23955)

Co-authored-by: Lari Hotari <[email protected]>
(cherry picked from commit 20b3b22)
lhotari added a commit that referenced this pull request Feb 10, 2025
@BewareMyPower @lhotari
[fix][ml] Fix memory leak due to duplicated RangeCache value retain o…
224320e
…perations (#23955)

Co-authored-by: Lari Hotari <[email protected]>
(cherry picked from commit 20b3b22)
@lhotari lhotari added cherry-picked/branch-3.0 cherry-picked/branch-3.3 cherry-picked/branch-4.0 labels Feb 10, 2025
@lhotari

lhotari commented Feb 10, 2025

Copy link
Copy Markdown
Member

I have created #23956 (WIP, draft) to address future memory leak regressions. It seems that there are quite a few tests where leaks happen currently and some of them are hard to fix. I have added a solution where it's possible to ignore specific test classes.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@BewareMyPower
BewareMyPower deleted the bewaremypower/fix-read-limiter branch February 11, 2025 01:46
nodece pushed a commit to ascentstream/pulsar that referenced this pull request Feb 11, 2025
@BewareMyPower @lhotari @nodece
[fix][ml] Fix memory leak due to duplicated RangeCache value retain o…
07c623c
…perations (apache#23955)

Co-authored-by: Lari Hotari <[email protected]>
(cherry picked from commit 20b3b22)
hanmz pushed a commit to hanmz/pulsar that referenced this pull request Feb 12, 2025
@BewareMyPower @lhotari hanmz
[fix][ml] Fix memory leak due to duplicated RangeCache value retain o…
a75cf1f
…perations (apache#23955)

Co-authored-by: Lari Hotari <[email protected]>
nikhil-ctds pushed a commit to datastax/pulsar that referenced this pull request Feb 19, 2025
@BewareMyPower @lhotari @nikhil-ctds
[fix][ml] Fix memory leak due to duplicated RangeCache value retain o…
8dec18f
…perations (apache#23955)

Co-authored-by: Lari Hotari <[email protected]>
(cherry picked from commit 20b3b22)
(cherry picked from commit 224320e)
mukesh-ctds pushed a commit to datastax/pulsar that referenced this pull request Feb 20, 2025
@BewareMyPower @lhotari @mukesh-ctds
[fix][ml] Fix memory leak due to duplicated RangeCache value retain o…
30390b2
…perations (apache#23955)

Co-authored-by: Lari Hotari <[email protected]>
(cherry picked from commit 20b3b22)
(cherry picked from commit dafd347)
srinath-ctds pushed a commit to datastax/pulsar that referenced this pull request Feb 24, 2025
@BewareMyPower @lhotari @srinath-ctds
[fix][ml] Fix memory leak due to duplicated RangeCache value retain o…
63b65a5
…perations (apache#23955)

Co-authored-by: Lari Hotari <[email protected]>
(cherry picked from commit 20b3b22)
(cherry picked from commit 224320e)
@lhotari lhotari mentioned this pull request May 31, 2025
[refactor][ml] Replace cache eviction algorithm with centralized removal queue and job #24363
Merged
1 of 4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@lhotari lhotari lhotari approved these changes
@codelipenghui codelipenghui Awaiting requested review from codelipenghui
@poorbarcode poorbarcode Awaiting requested review from poorbarcode
@shibd shibd Awaiting requested review from shibd
@mattisonchao mattisonchao Awaiting requested review from mattisonchao
@heesung-sohn heesung-sohn Awaiting requested review from heesung-sohn

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@BewareMyPower BewareMyPower

Labels

cherry-picked/branch-3.0 cherry-picked/branch-3.3 cherry-picked/branch-4.0 doc-not-needed Your PR changes do not impact docs release/3.0.10 release/3.3.5 release/4.0.3 type/bug The PR fixed a bug or issue reported a bug

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@BewareMyPower @lhotari @codecov-commenter
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.