You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by se...@apache.org on 2019/05/07 23:04:21 UTC

[hbase] branch branch-2 updated: HBASE-22360 Abort timer doesn't set when abort is called during graceful shutdown process

This is an automated email from the ASF dual-hosted git repository.

sershe pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-2 by this push:
     new 82fd46e  HBASE-22360 Abort timer doesn't set when abort is called during graceful shutdown process
82fd46e is described below

commit 82fd46e04b37ed966066220101fc7d2e38bc875e
Author: Bahram Chehrazy <ba...@microsoft.com>
AuthorDate: Tue May 7 15:48:59 2019 -0700

    HBASE-22360 Abort timer doesn't set when abort is called during graceful shutdown process
    
    Signed-off-by: Sergey Shelukhin <se...@apache.org>
---
 .../hadoop/hbase/regionserver/HRegionServer.java   | 38 +++++++++++++---------
 1 file changed, 23 insertions(+), 15 deletions(-)

diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
index 2f7db23..9e77ab5 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
@@ -533,6 +533,9 @@ public class HRegionServer extends HasThread implements
   /**regionserver codec list **/
   public static final String REGIONSERVER_CODEC = "hbase.regionserver.codecs";
 
+  // A timer to shutdown the process if abort takes too long
+  private Timer abortMonitor;
+
   /**
    * Starts a HRegionServer at the default location
    */
@@ -1040,21 +1043,6 @@ public class HRegionServer extends HasThread implements
       }
     }
 
-    if (abortRequested) {
-      Timer abortMonitor = new Timer("Abort regionserver monitor", true);
-      TimerTask abortTimeoutTask = null;
-      try {
-        abortTimeoutTask =
-            Class.forName(conf.get(ABORT_TIMEOUT_TASK, SystemExitWhenAbortTimeout.class.getName()))
-                .asSubclass(TimerTask.class).getDeclaredConstructor().newInstance();
-      } catch (Exception e) {
-        LOG.warn("Initialize abort timeout task failed", e);
-      }
-      if (abortTimeoutTask != null) {
-        abortMonitor.schedule(abortTimeoutTask, conf.getLong(ABORT_TIMEOUT, DEFAULT_ABORT_TIMEOUT));
-      }
-    }
-
     if (this.leases != null) {
       this.leases.closeAfterLeasesExpire();
     }
@@ -2419,6 +2407,8 @@ public class HRegionServer extends HasThread implements
     } catch (Throwable t) {
       LOG.warn("Unable to report fatal error to master", t);
     }
+
+    scheduleAbortTimer();
     // shutdown should be run as the internal user
     stop(reason, true, null);
   }
@@ -2456,6 +2446,24 @@ public class HRegionServer extends HasThread implements
   protected void sendShutdownInterrupt() {
   }
 
+  // Limits the time spent in the shutdown process.
+  private void scheduleAbortTimer() {
+    if (this.abortMonitor == null) {
+      this.abortMonitor = new Timer("Abort regionserver monitor", true);
+      TimerTask abortTimeoutTask = null;
+      try {
+        abortTimeoutTask =
+          Class.forName(conf.get(ABORT_TIMEOUT_TASK, SystemExitWhenAbortTimeout.class.getName()))
+            .asSubclass(TimerTask.class).getDeclaredConstructor().newInstance();
+      } catch (Exception e) {
+        LOG.warn("Initialize abort timeout task failed", e);
+      }
+      if (abortTimeoutTask != null) {
+        abortMonitor.schedule(abortTimeoutTask, conf.getLong(ABORT_TIMEOUT, DEFAULT_ABORT_TIMEOUT));
+      }
+    }
+  }
+
   /**
    * Wait on all threads to finish. Presumption is that all closes and stops
    * have already been called.