bookkeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From si...@apache.org
Subject bookkeeper git commit: BOOKKEEPER-847: ArrayIndexOutOfBoundsException in LedgerFragmentReplicator::updateEnsembleInfo (zhaijia via sijie)
Date Tue, 21 Apr 2015 07:35:33 GMT
Repository: bookkeeper
Updated Branches:
  refs/heads/master fe6259c7e -> b24cd7fd8


BOOKKEEPER-847: ArrayIndexOutOfBoundsException in LedgerFragmentReplicator::updateEnsembleInfo
(zhaijia via sijie)


Project: http://git-wip-us.apache.org/repos/asf/bookkeeper/repo
Commit: http://git-wip-us.apache.org/repos/asf/bookkeeper/commit/b24cd7fd
Tree: http://git-wip-us.apache.org/repos/asf/bookkeeper/tree/b24cd7fd
Diff: http://git-wip-us.apache.org/repos/asf/bookkeeper/diff/b24cd7fd

Branch: refs/heads/master
Commit: b24cd7fd85bb3235036e660ff3a295dc939705e6
Parents: fe6259c
Author: Sijie Guo <sijie@apache.org>
Authored: Tue Apr 21 00:35:22 2015 -0700
Committer: Sijie Guo <sijie@apache.org>
Committed: Tue Apr 21 00:35:22 2015 -0700

----------------------------------------------------------------------
 CHANGES.txt                                     |  2 ++
 .../client/LedgerFragmentReplicator.java        | 20 ++++++++++++++++----
 2 files changed, 18 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/b24cd7fd/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index c36151d..9ce143b 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -34,6 +34,8 @@ Trunk (unreleased changes)
 
       BOOKKEEPER-840: Deadlock on flushLock on compaction (sijie)
 
+      BOOKKEEPER-847: ArrayIndexOutOfBoundsException in LedgerFragmentReplicator::updateEnsembleInfo
(zhaijia via sijie)
+
     IMPROVEMENTS:
 
       BOOKKEEPER-800: Expose whether a ledger is closed or not (ivank)

http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/b24cd7fd/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerFragmentReplicator.java
----------------------------------------------------------------------
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerFragmentReplicator.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerFragmentReplicator.java
index 4501524..2078245 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerFragmentReplicator.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerFragmentReplicator.java
@@ -345,10 +345,22 @@ public class LedgerFragmentReplicator {
         ArrayList<BookieSocketAddress> ensemble = lh.getLedgerMetadata()
                 .getEnsembles().get(fragmentStartId);
         int deadBookieIndex = ensemble.indexOf(oldBookie);
-        ensemble.remove(deadBookieIndex);
-        ensemble.add(deadBookieIndex, newBookie);
-        lh.writeLedgerConfig(new UpdateEnsembleCb(ensembleUpdatedCb,
-                fragmentStartId, lh, oldBookie, newBookie));
+
+        /*
+         * An update to the ensemble info might happen after re-reading ledger metadata.
+         * Such an update might reflect a change to the ensemble membership such that 
+         * it might not be necessary to replace the bookie.
+         */
+        if (deadBookieIndex >= 0) {
+            ensemble.remove(deadBookieIndex);
+            ensemble.add(deadBookieIndex, newBookie);
+            lh.writeLedgerConfig(new UpdateEnsembleCb(ensembleUpdatedCb,
+                        fragmentStartId, lh, oldBookie, newBookie));
+        }
+        else {
+            LOG.warn("Bookie {} doesn't exist in ensemble {} anymore.", oldBookie, ensemble);
+            ensembleUpdatedCb.processResult(BKException.Code.UnexpectedConditionException,
null, null);
+        }
     }
 
     /**


Mime
View raw message