Index: src/main/java/org/apache/hadoop/hbase/master/handler/ServerShutdownHandler.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/master/handler/ServerShutdownHandler.java (revision 1147013) +++ src/main/java/org/apache/hadoop/hbase/master/handler/ServerShutdownHandler.java (working copy) @@ -93,6 +93,40 @@ } /** + * Failed many times, shutdown processing + * @throws IOException + */ + private void loopVerifyAndAssignRoot() throws IOException { + int iTimes = this.server.getConfiguration().getInt( + "hbase.catalog.verification.times", 10); + + long waitTime = this.server.getConfiguration().getLong( + "hbase.catalog.verification.loop.time", 1000); + int iFlag = 0; + while (true) { + try { + verifyAndAssignRoot(); + break; + } catch (KeeperException e) { + this.server.abort("In server shutdown processing, assigning root", e); + throw new IOException("Aborting", e); + } catch (Exception e) { + if (iFlag >= iTimes) { + this.server.abort("verifyAndAssignRoot failed after" + iTimes + + " times retries, aborting", e); + throw new IOException("Aborting", e); + } + try { + Thread.sleep(waitTime); + } catch (InterruptedException e1) { + LOG.warn("Thread exception.", e1); + } + iFlag++; + } + } + } + + /** * @return True if the server we are processing was carrying -ROOT- */ boolean isCarryingRoot() { @@ -131,16 +165,7 @@ // Assign root and meta if we were carrying them. if (isCarryingRoot()) { // -ROOT- - try { - 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); - } + loopVerifyAndAssignRoot(); } // Carrying meta?