poorbarcode opened a new pull request, #25016:
URL: https://github.com/apache/pulsar/pull/25016

   ### Motivation
   
   Issue: if a user used a customized `ManagedLedger` implementation, which 
does not extend `ManagedLedgerImpl`, he will encounter a memory leak issue, you 
can reproduce it by the new test `testNoMemoryLeakWhenExpireMessages`
   
   https://github.com/apache/pulsar/pull/24606 improved the function `message 
expiration`, but forgot to release `EntryImpl` here: 
https://github.com/apache/pulsar/pull/24606/files#diff-5edf14cc6f25857d0cfdd26b2d3b3141230ecfb0dfa95aebf7583fd76ede4c4bR3918-R3929
   
   **PersistentTopic.java**
   ```
       public CompletableFuture<Boolean> 
isOldestMessageExpiredAsync(ManagedCursor cursor, int messageTTLInSeconds) {
           CompletableFuture<Boolean> res = new CompletableFuture<>();
           cursor.asyncGetNthEntry(1, IndividualDeletedEntries.Include, new 
AsyncCallbacks.ReadEntryCallback() {
               @Override
               public void readEntryComplete(Entry entry, Object ctx) {
                   long entryTimestamp = 0;
                   try {
                       res.complete(MessageImpl.isEntryExpired(
                               (int) (messageTTLInSeconds * 
MESSAGE_EXPIRY_THRESHOLD), entryTimestamp));
                   } catch (IOException e) {
                       log.warn("[{}] [{}] Error while getting the oldest 
message", topic, cursor.toString(), e);
                       res.complete(false);
                   }
                   // (Highlight) the entry that was read out is not released 
here, which causes a memory leak issue
               }
           }, null);
           return res;
       }
   ```
   
   ### Modifications
   
   - fix the bug
   
   ### Documentation
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   - [ ] `doc` <!-- Your PR contains doc changes. -->
   - [ ] `doc-required` <!-- Your PR changes impact docs and you will update 
later -->
   - [x] `doc-not-needed` <!-- Your PR changes do not impact docs -->
   - [ ] `doc-complete` <!-- Docs have been already added -->
   
   ### Matching PR in forked repository
   
   PR in forked repository: x


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to