Repository: bookkeeper Updated Branches: refs/heads/master bfa74f736 -> fe52b500c
read only bookie runs replicator and does not release the under replicated lock after failing ⦠only bookie Author: Siddharth Boobna <[email protected]> Reviewers: Sijie Guo <[email protected]> Closes #17 from sboobna/BOOKKEEPER-900 Project: http://git-wip-us.apache.org/repos/asf/bookkeeper/repo Commit: http://git-wip-us.apache.org/repos/asf/bookkeeper/commit/fe52b500 Tree: http://git-wip-us.apache.org/repos/asf/bookkeeper/tree/fe52b500 Diff: http://git-wip-us.apache.org/repos/asf/bookkeeper/diff/fe52b500 Branch: refs/heads/master Commit: fe52b500cfec1c93725fa967ad2d5e0e7350580c Parents: bfa74f7 Author: Siddharth Boobna <[email protected]> Authored: Mon Mar 7 22:16:03 2016 -0800 Committer: Sijie Guo <[email protected]> Committed: Mon Mar 7 22:16:03 2016 -0800 ---------------------------------------------------------------------- .../replication/ReplicationWorker.java | 1 + .../replication/TestReplicationWorker.java | 26 ++++++++++++-------- 2 files changed, 17 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/fe52b500/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/ReplicationWorker.java ---------------------------------------------------------------------- diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/ReplicationWorker.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/ReplicationWorker.java index 4239b6a..1a10667 100644 --- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/ReplicationWorker.java +++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/ReplicationWorker.java @@ -252,6 +252,7 @@ public class ReplicationWorker implements Runnable { LOG.warn("BKLedgerRecoveryException " + "while replicating the fragment", e); if (admin.getReadOnlyBookies().contains(targetBookie)) { + underreplicationManager.releaseUnderreplicatedLedger(ledgerIdToReplicate); throw new BKException.BKWriteOnReadOnlyBookieException(); } } http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/fe52b500/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/TestReplicationWorker.java ---------------------------------------------------------------------- diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/TestReplicationWorker.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/TestReplicationWorker.java index 9591ef8..8aebae4 100644 --- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/TestReplicationWorker.java +++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/TestReplicationWorker.java @@ -19,6 +19,17 @@ */ package org.apache.bookkeeper.replication; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertNull; + +import java.net.InetAddress; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.Map.Entry; +import java.util.Set; + import org.apache.bookkeeper.client.BKException; import org.apache.bookkeeper.client.BookKeeper; import org.apache.bookkeeper.client.ClientUtil; @@ -32,22 +43,12 @@ import org.apache.bookkeeper.net.BookieSocketAddress; import org.apache.bookkeeper.proto.BookieServer; import org.apache.bookkeeper.test.MultiLedgerManagerTestCase; import org.apache.bookkeeper.util.BookKeeperConstants; -import org.apache.bookkeeper.util.ZkUtils; import org.apache.bookkeeper.zookeeper.ZooKeeperClient; -import org.apache.bookkeeper.zookeeper.ZooKeeperWatcherBase; import org.apache.zookeeper.ZooKeeper; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.net.InetAddress; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.Map.Entry; -import java.util.Set; - -import static org.junit.Assert.*; - /** * Test the ReplicationWroker, where it has to replicate the fragments from * failed Bookies to given target Bookie. @@ -58,6 +59,7 @@ public class TestReplicationWorker extends MultiLedgerManagerTestCase { private static final Logger LOG = LoggerFactory .getLogger(TestReplicationWorker.class); private String basePath = ""; + private String baseLockPath = ""; private LedgerManagerFactory mFactory; private LedgerUnderreplicationManager underReplicationManager; private static byte[] data = "TestReplicationWorker".getBytes(); @@ -72,6 +74,9 @@ public class TestReplicationWorker extends MultiLedgerManagerTestCase { basePath = baseClientConf.getZkLedgersRootPath() + '/' + BookKeeperConstants.UNDER_REPLICATION_NODE + BookKeeperConstants.DEFAULT_ZK_LEDGERS_ROOT_PATH; + baseLockPath = baseClientConf.getZkLedgersRootPath() + '/' + + BookKeeperConstants.UNDER_REPLICATION_NODE + + "/locks"; baseConf.setRereplicationEntryBatchSize(3); } @@ -535,6 +540,7 @@ public class TestReplicationWorker extends MultiLedgerManagerTestCase { while (ReplicationTestUtil.isLedgerInUnderReplication(zkc, lh.getId(), basePath) && rw.isRunning()) { Thread.sleep(100); } + assertNull(zkc.exists(String.format("%s/urL%010d", baseLockPath, lh.getId()), false)); assertFalse("RW should shutdown if the bookie is readonly", rw.isRunning()); } finally { rw.shutdown();
