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 18:18:09 UTC

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

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

 ##########
 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;
+                                break;
+                            }
                         }
                     }
                 } catch (InterruptedException e) {
                     Thread.currentThread().interrupt();
-                    LOG.info("InterruptedException "
-                            + "while replicating fragments", e);
+                    LOG.info("InterruptedException while fencing the ledger {}"
+                            + " for rereplication of postponed ledgers", lh.getId(), e);
                 } catch (BKNoSuchLedgerExistsException bknsle) {
                     if (LOG.isDebugEnabled()) {
                         LOG.debug("Ledger was deleted, safe to continue", bknsle);
                     }
                 } catch (BKException e) {
-                    LOG.error("BKException while fencing the ledger"
-                            + " for rereplication of postponed ledgers", e);
+                    LOG.error("BKException while fencing the ledger {}"
+                            + " for rereplication of postponed ledgers", lh.getId(), e);
                 } finally {
                     try {
                         if (lh != null) {
                             lh.close();
                         }
                     } catch (InterruptedException e) {
                         Thread.currentThread().interrupt();
-                        LOG.info("InterruptedException while closing "
-                                + "ledger", e);
+                        LOG.info("InterruptedException while closing ledger", e);
 
 Review comment:
   Ledger id should be reported in log

----------------------------------------------------------------
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