hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jeffr...@apache.org
Subject svn commit: r1523407 - in /hbase/trunk/hbase-server/src: main/java/org/apache/hadoop/hbase/master/SplitLogManager.java main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java test/java/org/apache/hadoop/hbase/master/TestSplitLogManager.java
Date Sun, 15 Sep 2013 06:13:23 GMT
Author: jeffreyz
Date: Sun Sep 15 06:13:22 2013
New Revision: 1523407

URL: http://svn.apache.org/r1523407
Log:
hbase-9512: Regions can't get out InRecovery state sometimes when turn off distributeLogReplay
and restart a cluster

Modified:
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/SplitLogManager.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestSplitLogManager.java

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/SplitLogManager.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/SplitLogManager.java?rev=1523407&r1=1523406&r2=1523407&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/SplitLogManager.java
(original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/SplitLogManager.java
Sun Sep 15 06:13:22 2013
@@ -572,6 +572,9 @@ public class SplitLogManager extends Zoo
       throws KeeperException {
 
     if (!this.distributedLogReplay) {
+      // remove any regions in recovery from ZK which could happen when we turn the feature
on
+      // and later turn it off
+      ZKUtil.deleteChildrenRecursively(watcher, watcher.recoveringRegionsZNode);
       // the function is only used in distributedLogReplay mode when master is in initialization
       return;
     }

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java?rev=1523407&r1=1523406&r2=1523407&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
(original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
Sun Sep 15 06:13:22 2013
@@ -3571,7 +3571,8 @@ public class HRegionServer implements Cl
 
         if (previous == null) {
           // check if the region to be opened is marked in recovering state in ZK
-          if (SplitLogManager.isRegionMarkedRecoveringInZK(this.getZooKeeper(),
+          if (this.distributedLogReplay
+              && SplitLogManager.isRegionMarkedRecoveringInZK(this.getZooKeeper(),
             region.getEncodedName())) {
             this.recoveringRegions.put(region.getEncodedName(), null);
           }

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestSplitLogManager.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestSplitLogManager.java?rev=1523407&r1=1523406&r2=1523407&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestSplitLogManager.java
(original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestSplitLogManager.java
Sun Sep 15 06:13:22 2013
@@ -39,6 +39,7 @@ import static org.junit.Assert.assertFal
 import static org.junit.Assert.assertTrue;
 
 import java.io.IOException;
+import java.util.List;
 import java.util.UUID;
 import java.util.concurrent.atomic.AtomicLong;
 
@@ -48,6 +49,8 @@ import org.apache.hadoop.conf.Configurat
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hbase.HBaseTestingUtility;
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.MediumTests;
 import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.SplitLogTask;
@@ -532,4 +535,27 @@ public class TestSplitLogManager {
       fs.delete(logDir, true);
     }
   }
+
+  /**
+   * The following test case is aiming to test the situation when distributedLogReplay is
turned off
+   * and restart a cluster there should no recovery regions in ZK left.
+   * @throws Exception
+   */
+  @Test(timeout = 300000)
+  public void testRecoveryRegionRemovedFromZK() throws Exception {
+    LOG.info("testRecoveryRegionRemovedFromZK");
+    conf.setBoolean(HConstants.DISTRIBUTED_LOG_REPLAY_KEY, false);
+    String nodePath =
+        ZKUtil.joinZNode(zkw.recoveringRegionsZNode,
+          HRegionInfo.FIRST_META_REGIONINFO.getEncodedName());
+    ZKUtil.createSetData(zkw, nodePath, ZKUtil.positionToByteArray(0L));
+
+    slm = new SplitLogManager(zkw, conf, stopper, master, DUMMY_MASTER);
+    slm.removeStaleRecoveringRegionsFromZK(null);
+
+    List<String> recoveringRegions =
+        zkw.getRecoverableZooKeeper().getChildren(zkw.recoveringRegionsZNode, false);
+
+    assertTrue("Recovery regions isn't cleaned", recoveringRegions.isEmpty());
+  }
 }



Mime
View raw message