Index: src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java (revision 1126829) +++ src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java (working copy) @@ -1176,6 +1176,24 @@ } /** + * Before assign the ROOT region, ensure it haven't + * been assigned by other place + *

+ * 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 + */ + public void verifyAndAssignRoot() + throws InterruptedException, IOException, KeeperException { + long timeout = master.getConfiguration().getLong("hbase.catalog.verification.timeout", 1000); + if (!catalogTracker.verifyRootRegionLocation(timeout)) { + assignRoot(); + } + } + /** * Assigns the META region. *

* Assumes that META is currently closed and is not being actively served by Index: src/main/java/org/apache/hadoop/hbase/master/handler/ServerShutdownHandler.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/master/handler/ServerShutdownHandler.java (revision 1126829) +++ src/main/java/org/apache/hadoop/hbase/master/handler/ServerShutdownHandler.java (working copy) @@ -104,10 +104,14 @@ // Assign root and meta if we were carrying them. if (isCarryingRoot()) { // -ROOT- try { - this.services.getAssignmentManager().assignRoot(); + this.services.getAssignmentManager().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); + throw new IOException(e1); } }