Skip to content

Commit d9491c0

Browse files
Bahram Chehrazysershe-apache
authored andcommitted
HBASE-22360 Abort timer doesn't set when abort is called during graceful shutdown process
Signed-off-by: Sergey Shelukhin <sershe@apache.org>
1 parent b5b89f7 commit d9491c0

1 file changed

Lines changed: 23 additions & 15 deletions

File tree

hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,9 @@ public class HRegionServer extends HasThread implements
537537
/**regionserver codec list **/
538538
public static final String REGIONSERVER_CODEC = "hbase.regionserver.codecs";
539539

540+
// A timer to shutdown the process if abort takes too long
541+
private Timer abortMonitor;
542+
540543
/**
541544
* Starts a HRegionServer at the default location
542545
*/
@@ -1047,21 +1050,6 @@ public void run() {
10471050
}
10481051
}
10491052

1050-
if (abortRequested) {
1051-
Timer abortMonitor = new Timer("Abort regionserver monitor", true);
1052-
TimerTask abortTimeoutTask = null;
1053-
try {
1054-
abortTimeoutTask =
1055-
Class.forName(conf.get(ABORT_TIMEOUT_TASK, SystemExitWhenAbortTimeout.class.getName()))
1056-
.asSubclass(TimerTask.class).getDeclaredConstructor().newInstance();
1057-
} catch (Exception e) {
1058-
LOG.warn("Initialize abort timeout task failed", e);
1059-
}
1060-
if (abortTimeoutTask != null) {
1061-
abortMonitor.schedule(abortTimeoutTask, conf.getLong(ABORT_TIMEOUT, DEFAULT_ABORT_TIMEOUT));
1062-
}
1063-
}
1064-
10651053
if (this.leases != null) {
10661054
this.leases.closeAfterLeasesExpire();
10671055
}
@@ -2448,6 +2436,8 @@ public void abort(String reason, Throwable cause) {
24482436
} catch (Throwable t) {
24492437
LOG.warn("Unable to report fatal error to master", t);
24502438
}
2439+
2440+
scheduleAbortTimer();
24512441
// shutdown should be run as the internal user
24522442
stop(reason, true, null);
24532443
}
@@ -2485,6 +2475,24 @@ protected void kill() {
24852475
protected void sendShutdownInterrupt() {
24862476
}
24872477

2478+
// Limits the time spent in the shutdown process.
2479+
private void scheduleAbortTimer() {
2480+
if (this.abortMonitor == null) {
2481+
this.abortMonitor = new Timer("Abort regionserver monitor", true);
2482+
TimerTask abortTimeoutTask = null;
2483+
try {
2484+
abortTimeoutTask =
2485+
Class.forName(conf.get(ABORT_TIMEOUT_TASK, SystemExitWhenAbortTimeout.class.getName()))
2486+
.asSubclass(TimerTask.class).getDeclaredConstructor().newInstance();
2487+
} catch (Exception e) {
2488+
LOG.warn("Initialize abort timeout task failed", e);
2489+
}
2490+
if (abortTimeoutTask != null) {
2491+
abortMonitor.schedule(abortTimeoutTask, conf.getLong(ABORT_TIMEOUT, DEFAULT_ABORT_TIMEOUT));
2492+
}
2493+
}
2494+
}
2495+
24882496
/**
24892497
* Wait on all threads to finish. Presumption is that all closes and stops
24902498
* have already been called.

0 commit comments

Comments
 (0)