You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2011/05/24 19:25:42 UTC

svn commit: r1127158 - in /hbase/trunk: CHANGES.txt src/main/java/org/apache/hadoop/hbase/master/handler/ServerShutdownHandler.java

Author: stack
Date: Tue May 24 17:25:42 2011
New Revision: 1127158

URL: http://svn.apache.org/viewvc?rev=1127158&view=rev
Log:
HBASE-3914 ROOT region appeared in two regionserver's onlineRegions at the same time

Modified:
    hbase/trunk/CHANGES.txt
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/handler/ServerShutdownHandler.java

Modified: hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/trunk/CHANGES.txt?rev=1127158&r1=1127157&r2=1127158&view=diff
==============================================================================
--- hbase/trunk/CHANGES.txt (original)
+++ hbase/trunk/CHANGES.txt Tue May 24 17:25:42 2011
@@ -285,6 +285,8 @@ Release 0.90.4 - Unreleased
    HBASE-3908  TableSplit not implementing "hashCode" problem (Daniel Iancu)
    HBASE-3915  Binary row keys in hbck and other miscellaneous binary key
                display issues
+   HBASE-3914  ROOT region appeared in two regionserver's onlineRegions at
+               the same time (Jieshan Bean)
 
   IMPROVEMENT
    HBASE-3882  hbase-config.sh needs to be updated so it can auto-detects the

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/handler/ServerShutdownHandler.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/handler/ServerShutdownHandler.java?rev=1127158&r1=1127157&r2=1127158&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/handler/ServerShutdownHandler.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/handler/ServerShutdownHandler.java Tue May 24 17:25:42 2011
@@ -74,6 +74,26 @@ public class ServerShutdownHandler exten
   }
 
   /**
+   * Before assign the ROOT region, ensure it haven't 
+   *  been assigned by other place
+   * <p>
+   * Under some scenarios, the ROOT region can be opened twice, so it seemed online
+   * in two regionserver at the same time.
+   * If the ROOT region has been assigned, so the operation can be canceled. 
+   * @throws InterruptedException
+   * @throws IOException
+   * @throws KeeperException
+   */
+  private void verifyAndAssignRoot() 
+  throws InterruptedException, IOException, KeeperException {
+    long timeout = this.server.getConfiguration().
+      getLong("hbase.catalog.verification.timeout", 1000);
+    if (!this.server.getCatalogTracker().verifyRootRegionLocation(timeout)) {
+      this.services.getAssignmentManager().assignRoot();     
+    }
+  }
+  
+  /**
    * @return True if the server we are processing was carrying <code>-ROOT-</code>
    */
   boolean isCarryingRoot() {
@@ -104,10 +124,14 @@ public class ServerShutdownHandler exten
     // Assign root and meta if we were carrying them.
     if (isCarryingRoot()) { // -ROOT-
       try {
-        this.services.getAssignmentManager().assignRoot();
+        verifyAndAssignRoot();
       } catch (KeeperException e) {
         this.server.abort("In server shutdown processing, assigning root", e);
         throw new IOException("Aborting", e);
+      } catch (InterruptedException e1) {
+        LOG.warn("Interrupted while verifying root region's location", e1);
+        Thread.currentThread().interrupt();
+        throw new IOException(e1);  
       }
     }
 
@@ -312,4 +336,4 @@ public class ServerShutdownHandler exten
       return false;
     }
   }
-}
\ No newline at end of file
+}