Repository: hbase
Updated Branches:
  refs/heads/master c1660a796 -> 4ed32bd77


HBASE-11687 No need to abort on postOpenDeployTasks exception if region opening 
is cancelled


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/4ed32bd7
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/4ed32bd7
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/4ed32bd7

Branch: refs/heads/master
Commit: 4ed32bd77eb17ee5ca674b37aeb097741590cad0
Parents: c1660a7
Author: Jimmy Xiang <[email protected]>
Authored: Tue Aug 12 15:49:03 2014 -0700
Committer: Jimmy Xiang <[email protected]>
Committed: Thu Aug 14 09:06:22 2014 -0700

----------------------------------------------------------------------
 .../regionserver/handler/OpenRegionHandler.java | 34 +++++++++-----------
 1 file changed, 16 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/4ed32bd7/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java
----------------------------------------------------------------------
diff --git 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java
 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java
index 20e0970..ce3a4a7 100644
--- 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java
+++ 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java
@@ -180,16 +180,8 @@ public class OpenRegionHandler extends EventHandler {
     // Post open deploy task:
     //   meta => update meta location in ZK
     //   other region => update meta
-    long now = System.currentTimeMillis();
-    long lastUpdate = now;
-    boolean tickleOpening = true;
     while (!signaller.get() && t.isAlive() && !this.server.isStopped() &&
         !this.rsServices.isStopping() && isRegionStillOpening()) {
-      long elapsed = now - lastUpdate;
-      if (elapsed > 120000) { // 2 minutes, no need to tickleOpening too often
-        // Only tickle OPENING if postOpenDeployTasks is taking some time.
-        lastUpdate = now;
-      }
       synchronized (signaller) {
         try {
           // Wait for 10 seconds, so that server shutdown
@@ -199,7 +191,6 @@ public class OpenRegionHandler extends EventHandler {
           // Go to the loop check.
         }
       }
-      now = System.currentTimeMillis();
     }
     // Is thread still alive?  We may have left above loop because server is
     // stopping or we timed out the edit.  Is so, interrupt it.
@@ -219,9 +210,8 @@ public class OpenRegionHandler extends EventHandler {
     }
 
     // Was there an exception opening the region?  This should trigger on
-    // InterruptedException too.  If so, we failed.  Even if tickle opening 
fails
-    // then it is a failure.
-    return ((!Thread.interrupted() && t.getException() == null) && 
tickleOpening);
+    // InterruptedException too.  If so, we failed.
+    return (!Thread.interrupted() && t.getException() == null);
   }
 
   /**
@@ -249,13 +239,16 @@ public class OpenRegionHandler extends EventHandler {
     public void run() {
       try {
         this.services.postOpenDeployTasks(this.region);
-      } catch (IOException e) {
-        server.abort("Exception running postOpenDeployTasks; region=" +
-            this.region.getRegionInfo().getEncodedName(), e);
       } catch (Throwable e) {
-        LOG.warn("Exception running postOpenDeployTasks; region=" +
-          this.region.getRegionInfo().getEncodedName(), e);
+        String msg = "Exception running postOpenDeployTasks; region=" +
+          this.region.getRegionInfo().getEncodedName();
         this.exception = e;
+        if (e instanceof IOException
+            && isRegionStillOpening(region.getRegionInfo(), services)) {
+          server.abort(msg, e);
+        } else {
+          LOG.warn(msg, e);
+        }
       }
       // We're done.  Set flag then wake up anyone waiting on thread to 
complete.
       this.signaller.set(true);
@@ -319,9 +312,14 @@ public class OpenRegionHandler extends EventHandler {
     }
   }
 
-  private boolean isRegionStillOpening() {
+  private static boolean isRegionStillOpening(
+      HRegionInfo regionInfo, RegionServerServices rsServices) {
     byte[] encodedName = regionInfo.getEncodedNameAsBytes();
     Boolean action = rsServices.getRegionsInTransitionInRS().get(encodedName);
     return Boolean.TRUE.equals(action); // true means opening for RIT
   }
+
+  private boolean isRegionStillOpening() {
+    return isRegionStillOpening(regionInfo, rsServices);
+  }
 }

Reply via email to