This is an automated email from the ASF dual-hosted git repository.

mmerli pushed a commit to branch branch-4.17
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git

commit 9b8e5666ba17ba3c6d5aa5bd4b671e806627d796
Author: Yan Zhao <[email protected]>
AuthorDate: Wed May 28 10:07:27 2025 +0800

    Fix check read failed entry memory leak issue. (#4513)
    
    * Fix check read failed entry memory leak issue.
    
    * address the comments.
---
 .../java/org/apache/bookkeeper/replication/ReplicationWorker.java    | 5 +++++
 1 file changed, 5 insertions(+)

diff --git 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/ReplicationWorker.java
 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/ReplicationWorker.java
index cf1f2f2f59..05807455dc 100644
--- 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/ReplicationWorker.java
+++ 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/ReplicationWorker.java
@@ -61,6 +61,7 @@ import org.apache.bookkeeper.client.BookKeeper;
 import org.apache.bookkeeper.client.BookKeeperAdmin;
 import org.apache.bookkeeper.client.EnsemblePlacementPolicy;
 import org.apache.bookkeeper.client.LedgerChecker;
+import org.apache.bookkeeper.client.LedgerEntry;
 import org.apache.bookkeeper.client.LedgerFragment;
 import org.apache.bookkeeper.client.LedgerHandle;
 import org.apache.bookkeeper.client.api.LedgerMetadata;
@@ -351,6 +352,10 @@ public class ReplicationWorker implements Runnable {
             lh.asyncReadEntries(entryIdToRead, entryIdToRead, (rc, ledHan, 
seq, ctx) -> {
                 long thisEntryId = (Long) ctx;
                 if (rc == BKException.Code.OK) {
+                    while (seq.hasMoreElements()) {
+                        LedgerEntry entry = seq.nextElement();
+                        entry.getEntryBuffer().release();
+                    }
                     entriesUnableToReadForThisLedger.remove(thisEntryId);
                     if (numOfResponsesToWaitFor.decrementAndGet() == 0) {
                         multiReadComplete.countDown();

Reply via email to