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 2018/02/11 20:12:49 UTC

[GitHub] jvrao commented on a change in pull request #1140: Issue:1139 Add debug to replication fencing

jvrao commented on a change in pull request #1140: Issue:1139 Add debug to replication fencing
URL: https://github.com/apache/bookkeeper/pull/1140#discussion_r167447507
 
 

 ##########
 File path: bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/ReplicationWorker.java
 ##########
 @@ -364,40 +368,52 @@ private void deferLedgerLockRelease(final long ledgerId) {
         TimerTask timerTask = new TimerTask() {
             @Override
             public void run() {
+                boolean isRecoveryOpen = false;
                 LedgerHandle lh = null;
                 try {
                     lh = admin.openLedgerNoRecovery(ledgerId);
                     if (isLastSegmentOpenAndMissingBookies(lh)) {
+                        // Need recovery open, close the old ledger handle.
+                        lh.close();
+                        // Recovery open could result in client write failure.
+                        LOG.warn("Missing bookie(s) from last segment. Opening Ledger{} for Recovery.", ledgerId);
                         lh = admin.openLedger(ledgerId);
+                        isRecoveryOpen = true;
                     }
-
-                    Set<LedgerFragment> fragments = getUnderreplicatedFragments(lh);
-                    for (LedgerFragment fragment : fragments) {
-                        if (!fragment.isClosed()) {
-                            lh = admin.openLedger(ledgerId);
-                            break;
+                    if (!isRecoveryOpen){
+                        Set<LedgerFragment> fragments = getUnderreplicatedFragments(lh);
+                        for (LedgerFragment fragment : fragments) {
+                            if (!fragment.isClosed()) {
+                                // Need recovery open, close the old ledger handle.
+                                lh.close();
+                                // Recovery open could result in client write failure.
+                                LOG.warn("Open Fragment{}. Opening Ledger{} for Recovery.",
+                                        fragment.getEnsemble(), ledgerId);
+                                lh = admin.openLedger(ledgerId);
+                                isRecoveryOpen = true;
 
 Review comment:
   Agreed, but I kept it for consistency. Future code (any additional code branches below) should not worry about this not being set.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services