You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by mm...@apache.org on 2022/08/09 20:37:32 UTC
[pulsar] branch branch-2.11 updated: [fix][broker] Fix memory leak if entry exists in cache (#16996)
This is an automated email from the ASF dual-hosted git repository.
mmarshall pushed a commit to branch branch-2.11
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/branch-2.11 by this push:
new 5c9947744b5 [fix][broker] Fix memory leak if entry exists in cache (#16996)
5c9947744b5 is described below
commit 5c9947744b55333dfee9f94bdf78f528b9d09070
Author: Lei Zhiyuan <le...@gmail.com>
AuthorDate: Wed Aug 10 04:29:04 2022 +0800
[fix][broker] Fix memory leak if entry exists in cache (#16996)
* feat:return true if entry exists in cache
* feat:return true if entry exists in cache
* chore: add comment
Co-authored-by: zhiyuanlei <zh...@tencent.com>
Master Issue: #16979
### Motivation
PR https://github.com/apache/pulsar/pull/12258 made changes to OpAddEntry which causes a memory leak when the entry is already in the cache.
### Modifications
Modifications: Revert PR https://github.com/apache/pulsar/pull/12258 changes to OpAddEntry
### Documentation
- [x] `doc-not-needed`
(cherry picked from commit 374b3a18155cba33c4b4cfdb18c8119487be565e)
---
.../main/java/org/apache/bookkeeper/mledger/impl/OpAddEntry.java | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/OpAddEntry.java b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/OpAddEntry.java
index 689385ee571..c25fa4f4d51 100644
--- a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/OpAddEntry.java
+++ b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/OpAddEntry.java
@@ -213,11 +213,8 @@ public class OpAddEntry extends SafeRunnable implements AddCallback, CloseCallba
EntryImpl entry = EntryImpl.create(ledger.getId(), entryId, data);
// EntryCache.insert: duplicates entry by allocating new entry and data. so, recycle entry after calling
// insert
- // Entry cache doesn't copy the data if entry already exist into the cache.
- // Backlog read tries to add entry into cache which can try to add duplicate entry into cache.
- if (ml.entryCache.insert(entry)) {
- entry.release();
- }
+ ml.entryCache.insert(entry);
+ entry.release();
}
PositionImpl lastEntry = PositionImpl.get(ledger.getId(), entryId);