hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jeffr...@apache.org
Subject hbase git commit: HBASE-12319: Inconsistencies during region recovery due to close/open of a region during recovery
Date Wed, 12 Nov 2014 02:33:23 GMT
Repository: hbase
Updated Branches:
  refs/heads/0.98 f1a8f2fca -> 78c1a919c


HBASE-12319: Inconsistencies during region recovery due to close/open of a region during recovery


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

Branch: refs/heads/0.98
Commit: 78c1a919c906649427defdcaa17d8ab73bbb9482
Parents: f1a8f2f
Author: Jeffrey Zhong <jeffreyz@apache.org>
Authored: Tue Nov 11 18:32:28 2014 -0800
Committer: Jeffrey Zhong <jeffreyz@apache.org>
Committed: Tue Nov 11 18:32:28 2014 -0800

----------------------------------------------------------------------
 .../apache/hadoop/hbase/regionserver/HRegionServer.java |  2 +-
 .../hbase/regionserver/handler/OpenRegionHandler.java   | 12 +++++++++---
 .../hbase/master/TestAssignmentManagerOnCluster.java    |  4 +++-
 .../hbase/regionserver/TestRegionServerNoMaster.java    |  2 +-
 4 files changed, 14 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/78c1a919/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
index 703904d..d39311e 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
@@ -2664,7 +2664,7 @@ public class HRegionServer implements ClientProtos.ClientService.BlockingInterfa
       if (actualRegion == null) { // If already online, we still need to close it.
         LOG.info("The opening previously in progress has been cancelled by a CLOSE request.");
         // The master deletes the znode when it receives this exception.
-        throw new NotServingRegionException("The region " + encodedName +
+        throw new RegionAlreadyInTransitionException("The region " + encodedName +
           " was opening but not yet served. Opening is cancelled.");
       }
     } else if (Boolean.FALSE.equals(previous)) {

http://git-wip-us.apache.org/repos/asf/hbase/blob/78c1a919/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java
index 5a64731..7728c05 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java
@@ -148,7 +148,7 @@ public class OpenRegionHandler extends EventHandler {
       }
 
       boolean failed = true;
-      if (!useZKForAssignment || tickleOpening("post_region_open")) {
+      if (isRegionStillOpening() && (!useZKForAssignment || tickleOpening("post_region_open")))
{
         if (updateMeta(region)) {
           failed = false;
         }
@@ -520,8 +520,14 @@ public class OpenRegionHandler extends EventHandler {
 
   void cleanupFailedOpen(final HRegion region) throws IOException {
     if (region != null) {
-      this.rsServices.removeFromOnlineRegions(region, null);
-      region.close();
+      byte[] encodedName = regionInfo.getEncodedNameAsBytes();
+      try {
+        rsServices.getRegionsInTransitionInRS().put(encodedName,Boolean.FALSE);
+        this.rsServices.removeFromOnlineRegions(region, null);
+        region.close();
+      } finally {
+        rsServices.getRegionsInTransitionInRS().remove(encodedName);
+      }
     }
   }
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/78c1a919/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManagerOnCluster.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManagerOnCluster.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManagerOnCluster.java
index a31f125..e839108 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManagerOnCluster.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManagerOnCluster.java
@@ -745,7 +745,6 @@ public class TestAssignmentManagerOnCluster {
       // Let's forcefully re-assign it to trigger closing/opening
       // racing. This test is to make sure this scenario
       // is handled properly.
-      MyRegionObserver.postOpenEnabled.set(false);
       ServerName destServerName = null;
       int numRS = TEST_UTIL.getHBaseCluster().getLiveRegionServerThreads().size();
       for (int i = 0; i < numRS; i++) {
@@ -761,6 +760,9 @@ public class TestAssignmentManagerOnCluster {
       List<HRegionInfo> regions = new ArrayList<HRegionInfo>();
       regions.add(hri);
       am.assign(destServerName, regions);
+      
+      // let region open continue
+      MyRegionObserver.postOpenEnabled.set(false);
 
       // let's check if it's assigned after it's out of transition
       am.waitOnRegionToClearRegionsInTransition(hri);

http://git-wip-us.apache.org/repos/asf/hbase/blob/78c1a919/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerNoMaster.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerNoMaster.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerNoMaster.java
index 799a277..8606b02 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerNoMaster.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerNoMaster.java
@@ -354,7 +354,7 @@ public class TestRegionServerNoMaster {
       getRS().closeRegion(null, crr);
       Assert.assertTrue(false);
     } catch (ServiceException expected) {
-      Assert.assertTrue(expected.getCause() instanceof NotServingRegionException);
+      Assert.assertTrue(expected.getCause() instanceof RegionAlreadyInTransitionException);
     }
 
     // The close should have left the ZK state as it is: it's the job the AM to delete it


Mime
View raw message