hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From la...@apache.org
Subject svn commit: r1358820 - in /hbase/trunk/hbase-server/src: main/java/org/apache/hadoop/hbase/regionserver/ test/java/org/apache/hadoop/hbase/regionserver/
Date Sun, 08 Jul 2012 19:21:30 GMT
Author: larsh
Date: Sun Jul  8 19:21:30 2012
New Revision: 1358820

URL: http://svn.apache.org/viewvc?rev=1358820&view=rev
Log:
HBASE-6329 Stopping META regionserver when splitting region could cause daughter region to
be assigned twice (chunhui shen)

Modified:
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/SplitRequest.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/SplitTransaction.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestEndToEndSplitTransaction.java

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=1358820&r1=1358819&r2=1358820&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 Jul  8 19:21:30 2012
@@ -872,6 +872,11 @@ public class  HRegionServer implements C
       this.hbaseMaster = null;
     }
     this.leases.close();
+
+    if (!killed) {
+      join();
+    }
+
     try {
       deleteMyEphemeralNode();
     } catch (KeeperException e) {
@@ -884,9 +889,6 @@ public class  HRegionServer implements C
     LOG.info("stopping server " + this.serverNameFromMasterPOV +
       "; zookeeper connection closed.");
 
-    if (!killed) {
-      join();
-    }
     LOG.info(Thread.currentThread().getName() + " exiting");
   }
 
@@ -1634,6 +1636,7 @@ public class  HRegionServer implements C
   public void postOpenDeployTasks(final HRegion r, final CatalogTracker ct,
       final boolean daughter)
   throws KeeperException, IOException {
+    checkOpen();
     LOG.info("Post open deploy tasks for region=" + r.getRegionNameAsString() +
       ", daughter=" + daughter);
     // Do checks to see if we need to compact (references or too many files)

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/SplitRequest.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/SplitRequest.java?rev=1358820&r1=1358819&r2=1358820&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/SplitRequest.java
(original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/SplitRequest.java
Sun Jul  8 19:21:30 2012
@@ -69,6 +69,13 @@ class SplitRequest implements Runnable {
         st.execute(this.server, this.server);
         this.server.getMetrics().incrementSplitSuccessCount();
       } catch (Exception e) {
+        if (this.server.isStopping() || this.server.isStopped()) {
+          LOG.info(
+              "Skip rollback/cleanup of failed split of "
+                  + parent.getRegionNameAsString() + " because server is"
+                  + (this.server.isStopping() ? " stopping" : " stopped"), e);
+          return;
+        }
         try {
           LOG.info("Running rollback/cleanup of failed split of " +
             parent.getRegionNameAsString() + "; " + e.getMessage(), e);

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/SplitTransaction.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/SplitTransaction.java?rev=1358820&r1=1358819&r2=1358820&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/SplitTransaction.java
(original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/SplitTransaction.java
Sun Jul  8 19:21:30 2012
@@ -342,11 +342,6 @@ public class SplitTransaction {
     boolean stopping = services != null && services.isStopping();
     // TODO: Is this check needed here?
     if (stopped || stopping) {
-      // add 2nd daughter first (see HBASE-4335)
-      MetaEditor.addDaughter(server.getCatalogTracker(),
-          b.getRegionInfo(), services.getServerName());
-      MetaEditor.addDaughter(server.getCatalogTracker(),
-          a.getRegionInfo(), services.getServerName());
       LOG.info("Not opening daughters " +
           b.getRegionInfo().getRegionNameAsString() +
           " and " +
@@ -397,7 +392,8 @@ public class SplitTransaction {
    * @param a second daughter region
    * @throws IOException If thrown, transaction failed. Call {@link #rollback(Server, RegionServerServices)}
    */
-  /* package */void transitionZKNode(final Server server, HRegion a, HRegion b)
+  /* package */void transitionZKNode(final Server server,
+      final RegionServerServices services, HRegion a, HRegion b)
       throws IOException {
     // Tell master about split by updating zk.  If we fail, abort.
     if (server != null && server.getZooKeeper() != null) {
@@ -421,7 +417,8 @@ public class SplitTransaction {
             parent.getRegionInfo(), a.getRegionInfo(), b.getRegionInfo(),
             server.getServerName(), this.znodeVersion);
           spins++;
-        } while (this.znodeVersion != -1);
+        } while (this.znodeVersion != -1 && !server.isStopped()
+            && !services.isStopping());
       } catch (Exception e) {
         if (e instanceof InterruptedException) {
           Thread.currentThread().interrupt();
@@ -455,7 +452,7 @@ public class SplitTransaction {
   throws IOException {
     PairOfSameType<HRegion> regions = createDaughters(server, services);
     openDaughters(server, services, regions.getFirst(), regions.getSecond());
-    transitionZKNode(server, regions.getFirst(), regions.getSecond());
+    transitionZKNode(server, services, regions.getFirst(), regions.getSecond());
     return regions;
   }
 

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestEndToEndSplitTransaction.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestEndToEndSplitTransaction.java?rev=1358820&r1=1358819&r2=1358820&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestEndToEndSplitTransaction.java
(original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestEndToEndSplitTransaction.java
Sun Jul  8 19:21:30 2012
@@ -136,7 +136,8 @@ public class TestEndToEndSplitTransactio
     assertTrue(test(con, tableName, lastRow, server));
 
     // 4. phase III
-    split.transitionZKNode(server, regions.getFirst(), regions.getSecond());
+    split.transitionZKNode(server, server, regions.getFirst(),
+        regions.getSecond());
     assertTrue(test(con, tableName, firstRow, server));
     assertTrue(test(con, tableName, lastRow, server));
   }



Mime
View raw message