You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/08/09 03:34:09 UTC

[GitHub] [pulsar] codelipenghui commented on a diff in pull request #12258: [pulsar-broker] Support caching to drain backlog consumers

codelipenghui commented on code in PR #12258:
URL: https://github.com/apache/pulsar/pull/12258#discussion_r940860505


##########
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/OpAddEntry.java:
##########
@@ -213,8 +213,11 @@ 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
-            ml.entryCache.insert(entry);
-            entry.release();
+            // 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();
+            }

Review Comment:
   Here will be a potential memory leak? If the cache doesn't have enough space, will the entry not be released?



-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org