You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@bookkeeper.apache.org by GitBox <gi...@apache.org> on 2021/11/20 13:26:05 UTC

[GitHub] [bookkeeper] jadireddi opened a new pull request #2903: ISSUE-2770: Code refactor calling ledgerExists two times.

jadireddi opened a new pull request #2903:
URL: https://github.com/apache/bookkeeper/pull/2903


   
   ### Changes
   SortedLedgerStorage's method `ledgerExists`, is being called two times to check for the ledger exists or not. Refactored to call only once.
   
   Master Issue: https://github.com/apache/bookkeeper/issues/2770
   


-- 
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: issues-unsubscribe@bookkeeper.apache.org

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



[GitHub] [bookkeeper] eolivelli commented on a change in pull request #2903: ISSUE-2770: Code refactor calling ledgerExists two times.

Posted by GitBox <gi...@apache.org>.
eolivelli commented on a change in pull request #2903:
URL: https://github.com/apache/bookkeeper/pull/2903#discussion_r753683302



##########
File path: bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/SortedLedgerStorage.java
##########
@@ -144,9 +144,7 @@ public boolean ledgerExists(long ledgerId) throws IOException {
         // the O(1) for the ledgerCache.
         if (!interleavedLedgerStorage.ledgerExists(ledgerId)) {
             EntryKeyValue kv = memTable.getLastEntry(ledgerId);
-            if (null == kv) {
-                return interleavedLedgerStorage.ledgerExists(ledgerId);

Review comment:
       I have seen this patch before.
   Maybe there is already another open PR
   
   My question is...
   Why this code was written the way it is?
   In order to deal with some possible race condition ?
   
   @merlimat do you know?




-- 
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: issues-unsubscribe@bookkeeper.apache.org

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



[GitHub] [bookkeeper] eolivelli commented on a change in pull request #2903: ISSUE-2770: Code refactor calling ledgerExists two times.

Posted by GitBox <gi...@apache.org>.
eolivelli commented on a change in pull request #2903:
URL: https://github.com/apache/bookkeeper/pull/2903#discussion_r753683302



##########
File path: bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/SortedLedgerStorage.java
##########
@@ -144,9 +144,7 @@ public boolean ledgerExists(long ledgerId) throws IOException {
         // the O(1) for the ledgerCache.
         if (!interleavedLedgerStorage.ledgerExists(ledgerId)) {
             EntryKeyValue kv = memTable.getLastEntry(ledgerId);
-            if (null == kv) {
-                return interleavedLedgerStorage.ledgerExists(ledgerId);

Review comment:
       I have seen this patch before.
   Maybe there is already another open PR
   
   My question is...
   Why this code was written the way it is?
   In order to deal with some possible race condition ?
   
   @merlimat do you know?




-- 
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: issues-unsubscribe@bookkeeper.apache.org

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