hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ramkris...@apache.org
Subject svn commit: r1443637 - in /hbase/trunk/hbase-server/src: main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java test/java/org/apache/hadoop/hbase/regionserver/handler/TestOpenRegionHandler.java
Date Thu, 07 Feb 2013 18:07:56 GMT
Author: ramkrishna
Date: Thu Feb  7 18:07:56 2013
New Revision: 1443637

URL: http://svn.apache.org/r1443637
Log:
HBASE-7698 race between RS shutdown thread and openregionhandler causes region to get stuck
(Ram)


Modified:
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/handler/TestOpenRegionHandler.java

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java?rev=1443637&r1=1443636&r2=1443637&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java
(original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java
Thu Feb  7 18:07:56 2013
@@ -87,6 +87,7 @@ public class OpenRegionHandler extends E
   @Override
   public void process() throws IOException {
     boolean openSuccessful = false;
+    boolean transitionToFailedOpen = false;
     final String regionName = regionInfo.getRegionNameAsString();
 
     try {
@@ -130,6 +131,7 @@ public class OpenRegionHandler extends E
       HRegion region = openRegion();
       if (region == null) {
         tryTransitionFromOpeningToFailedOpen(regionInfo);
+        transitionToFailedOpen = true;
         return;
       }
       boolean failed = true;
@@ -142,6 +144,7 @@ public class OpenRegionHandler extends E
           this.rsServices.isStopping()) {
         cleanupFailedOpen(region);
         tryTransitionFromOpeningToFailedOpen(regionInfo);
+        transitionToFailedOpen = true;
         return;
       }
 
@@ -154,6 +157,7 @@ public class OpenRegionHandler extends E
         // In all cases, we try to transition to failed_open to be safe.
         cleanupFailedOpen(region);
         tryTransitionFromOpeningToFailedOpen(regionInfo);
+        transitionToFailedOpen = true;
         return;
       }
 
@@ -197,6 +201,8 @@ public class OpenRegionHandler extends E
               " should be closed is now opened."
           );
         }
+      } else if (transitionToFailedOpen == false) {
+        tryTransitionFromOpeningToFailedOpen(regionInfo);
       }
     }
   }
@@ -455,7 +461,7 @@ public class OpenRegionHandler extends E
     return region;
   }
 
-  private void cleanupFailedOpen(final HRegion region) throws IOException {
+  void cleanupFailedOpen(final HRegion region) throws IOException {
     if (region != null) region.close();
   }
 

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/handler/TestOpenRegionHandler.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/handler/TestOpenRegionHandler.java?rev=1443637&r1=1443636&r2=1443637&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/handler/TestOpenRegionHandler.java
(original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/handler/TestOpenRegionHandler.java
Thu Feb  7 18:07:56 2013
@@ -184,6 +184,33 @@ public class TestOpenRegionHandler {
     assertEquals(EventType.RS_ZK_REGION_FAILED_OPEN, rt.getEventType());
   }
   
+  @Test
+  public void testTransitionToFailedOpenEvenIfCleanupFails() throws Exception {
+    Server server = new MockServer(HTU);
+    RegionServerServices rsServices = new MockRegionServerServices();
+    // Create it OFFLINE, which is what it expects
+    ZKAssign.createNodeOffline(server.getZooKeeper(), TEST_HRI, server.getServerName());
+    // Create the handler
+    OpenRegionHandler handler = new OpenRegionHandler(server, rsServices, TEST_HRI, TEST_HTD)
{
+      @Override
+      boolean updateMeta(HRegion r) {
+        return false;
+      };
 
+      @Override
+      void cleanupFailedOpen(HRegion region) throws IOException {
+        throw new IOException("FileSystem got closed.");
+      }
+    };
+    rsServices.getRegionsInTransitionInRS().put(TEST_HRI.getEncodedNameAsBytes(), Boolean.TRUE);
+    try {
+      handler.process();
+    } catch (Exception e) {
+      // Ignore the IOException that we have thrown from cleanupFailedOpen
+    }
+    RegionTransition rt = RegionTransition.parseFrom(ZKAssign.getData(server.getZooKeeper(),
+        TEST_HRI.getEncodedName()));
+    assertEquals(EventType.RS_ZK_REGION_FAILED_OPEN, rt.getEventType());
+  }
 }
 



Mime
View raw message