zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From si...@apache.org
Subject svn commit: r1496708 - in /zookeeper/bookkeeper/branches/branch-4.2: CHANGES.txt bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerChecker.java bookkeeper-server/src/test/java/org/apache/bookkeeper/client/LedgerCloseTest.java
Date Wed, 26 Jun 2013 01:45:58 GMT
Author: sijie
Date: Wed Jun 26 01:45:58 2013
New Revision: 1496708

URL: http://svn.apache.org/r1496708
Log:
BOOKKEEPER-623: LedgerChecker should avoid segments of closed ledger with higher start entryId
than closed entry. (vinay via sijie)

Modified:
    zookeeper/bookkeeper/branches/branch-4.2/CHANGES.txt
    zookeeper/bookkeeper/branches/branch-4.2/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerChecker.java
    zookeeper/bookkeeper/branches/branch-4.2/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/LedgerCloseTest.java

Modified: zookeeper/bookkeeper/branches/branch-4.2/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/branches/branch-4.2/CHANGES.txt?rev=1496708&r1=1496707&r2=1496708&view=diff
==============================================================================
--- zookeeper/bookkeeper/branches/branch-4.2/CHANGES.txt (original)
+++ zookeeper/bookkeeper/branches/branch-4.2/CHANGES.txt Wed Jun 26 01:45:58 2013
@@ -27,8 +27,11 @@ Release 4.2.2 - Unreleased
 	BOOKKEEPER-626: BOOKIE_EXTRA_OPTS are added twice (vinay via fpj)
 
         BOOKKEEPER-619: Bookie should not create local cookie files if zookeeper is uninitialized
(ivank)
+
         BOOKKEEPER-313: Bookkeeper shutdown call from Bookie thread is not shutting down
server (vinay via ivank)
 
+        BOOKKEEPER-623: LedgerChecker should avoid segments of closed ledger with higher
start entryId than closed entry. (vinay via sijie)
+
       hedwig-server:
 
         BOOKKEEPER-579: TestSubAfterCloseSub was put in a wrong package (sijie via ivank)

Modified: zookeeper/bookkeeper/branches/branch-4.2/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerChecker.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/branches/branch-4.2/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerChecker.java?rev=1496708&r1=1496707&r2=1496708&view=diff
==============================================================================
--- zookeeper/bookkeeper/branches/branch-4.2/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerChecker.java
(original)
+++ zookeeper/bookkeeper/branches/branch-4.2/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerChecker.java
Wed Jun 26 01:45:58 2013
@@ -204,9 +204,7 @@ public class LedgerChecker {
          * NoSuchEntry we can assume it was never written. If they respond with anything
          * else, we must assume the entry has been written, so we run the check.
          */
-        if (curEntryId != null
-            && !(lh.getLastAddConfirmed() == LedgerHandle.INVALID_ENTRY_ID
-                 && lh.getLedgerMetadata().isClosed())) {
+        if (curEntryId != null && !(lh.getLedgerMetadata().isClosed() &&
lh.getLastAddConfirmed() < curEntryId)) {
             long lastEntry = lh.getLastAddConfirmed();
 
             if (lastEntry < curEntryId) {

Modified: zookeeper/bookkeeper/branches/branch-4.2/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/LedgerCloseTest.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/branches/branch-4.2/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/LedgerCloseTest.java?rev=1496708&r1=1496707&r2=1496708&view=diff
==============================================================================
--- zookeeper/bookkeeper/branches/branch-4.2/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/LedgerCloseTest.java
(original)
+++ zookeeper/bookkeeper/branches/branch-4.2/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/LedgerCloseTest.java
Wed Jun 26 01:45:58 2013
@@ -20,6 +20,7 @@ package org.apache.bookkeeper.client;
 import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.nio.ByteBuffer;
+import java.util.Set;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
@@ -29,6 +30,7 @@ import org.apache.bookkeeper.client.Asyn
 import org.apache.bookkeeper.client.BookKeeper.DigestType;
 import org.apache.bookkeeper.conf.ClientConfiguration;
 import org.apache.bookkeeper.conf.ServerConfiguration;
+import org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.GenericCallback;
 import org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.WriteCallback;
 import org.apache.bookkeeper.test.BookKeeperClusterTestCase;
 import org.junit.Test;
@@ -57,12 +59,50 @@ public class LedgerCloseTest extends Boo
     @Test(timeout = 60000)
     public void testLedgerCloseDuringUnrecoverableErrors() throws Exception {
         int numEntries = 3;
+        LedgerHandle lh = bkc.createLedger(3, 3, 3, digestType, "".getBytes());
+        verifyMetadataConsistency(numEntries, lh);
+    }
+
+    @Test(timeout = 60000)
+    public void testLedgerCheckerShouldnotSelectInvalidLastFragments() throws Exception {
+        int numEntries = 10;
+        LedgerHandle lh = bkc.createLedger(3, 3, 3, digestType, "".getBytes());
+        // Add some entries before bookie failures
+        for (int i = 0; i < numEntries; i++) {
+            lh.addEntry("data".getBytes());
+        }
+        numEntries = 4; // add n*ensemleSize+1 entries async after bookies
+                        // failed.
+        verifyMetadataConsistency(numEntries, lh);
+
+        LedgerChecker checker = new LedgerChecker(bkc);
+        CheckerCallback cb = new CheckerCallback();
+        checker.checkLedger(lh, cb);
+        Set<LedgerFragment> result = cb.waitAndGetResult();
+        assertEquals("No fragments should be selected", 0, result.size());
+    }
+
+    class CheckerCallback implements GenericCallback<Set<LedgerFragment>> {
+        private Set<LedgerFragment> result = null;
+        private CountDownLatch latch = new CountDownLatch(1);
+
+        public void operationComplete(int rc, Set<LedgerFragment> result) {
+            this.result = result;
+            latch.countDown();
+        }
+
+        Set<LedgerFragment> waitAndGetResult() throws InterruptedException {
+            latch.await();
+            return result;
+        }
+    }
+
+    private void verifyMetadataConsistency(int numEntries, LedgerHandle lh)
+            throws Exception {
         final CountDownLatch addDoneLatch = new CountDownLatch(1);
         final CountDownLatch deadIOLatch = new CountDownLatch(1);
         final CountDownLatch recoverDoneLatch = new CountDownLatch(1);
         final CountDownLatch failedLatch = new CountDownLatch(1);
-
-        LedgerHandle lh = bkc.createLedger(3, 3, 3, digestType, "".getBytes());
         // kill first bookie to replace with a unauthorize bookie
         InetSocketAddress bookie = lh.getLedgerMetadata().currentEnsemble.get(0);
         ServerConfiguration conf = killBookie(bookie);



Mime
View raw message