Skip to content

Commit

Permalink
[fix][broker] Fix memory leak if entry exists in cache (apache#16996)
Browse files Browse the repository at this point in the history
* feat:return true if entry exists in cache

* feat:return true if entry exists in cache

* chore: add comment

Co-authored-by: zhiyuanlei <zhiyuanlei@tencent.com>

Master Issue: apache#16979

### Motivation

PR apache#12258 made changes to OpAddEntry which causes a memory leak when the entry is already in the cache.

### Modifications

Modifications: Revert PR apache#12258 changes to OpAddEntry

### Documentation

- [x] `doc-not-needed`
  • Loading branch information
leizhiyuan authored Aug 9, 2022
1 parent be57e71 commit 374b3a1
Showing 1 changed file with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,8 @@ public void safeRun() {
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);
Expand Down

0 comments on commit 374b3a1

Please sign in to comment.