From 77e5668ed20b20c8b91128ee819927a26041272d Mon Sep 17 00:00:00 2001 From: Nihal Jain Date: Fri, 6 Jul 2018 00:42:58 +0530 Subject: [PATCH] HBASE-20808 Wrong shutdown order between Chores and ChoreService Signed-off-by: Reid Chan --- .../apache/hadoop/hbase/master/HMaster.java | 36 ++++++++----------- .../hbase/regionserver/HRegionServer.java | 21 ++++++----- 2 files changed, 24 insertions(+), 33 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java index cfa6aa2ecab..21ec23c762a 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java @@ -51,6 +51,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; +import org.apache.hadoop.hbase.ChoreService; import org.apache.hadoop.hbase.ClusterStatus; import org.apache.hadoop.hbase.CoordinatedStateException; import org.apache.hadoop.hbase.CoordinatedStateManager; @@ -1284,8 +1285,8 @@ public class HMaster extends HRegionServer implements MasterServices, Server { LOG.error("Failed to stop master jetty server", e); } } - super.stopServiceThreads(); stopChores(); + super.stopServiceThreads(); CleanerChore.shutDownChorePool(); // Wait for all the remaining region servers to report in IFF we were @@ -1298,10 +1299,6 @@ public class HMaster extends HRegionServer implements MasterServices, Server { LOG.debug("Stopping service threads"); } // Clean up and close up shop - if (this.logCleaner != null) this.logCleaner.cancel(true); - if (this.hfileCleaner != null) this.hfileCleaner.cancel(true); - if (this.replicationZKLockCleanerChore != null) this.replicationZKLockCleanerChore.cancel(true); - if (this.replicationZKNodeCleanerChore != null) this.replicationZKNodeCleanerChore.cancel(true); if (this.quotaManager != null) this.quotaManager.stop(); if (this.activeMasterManager != null) this.activeMasterManager.stop(); if (this.serverManager != null) this.serverManager.stop(); @@ -1355,23 +1352,18 @@ public class HMaster extends HRegionServer implements MasterServices, Server { } private void stopChores() { - if (this.balancerChore != null) { - this.balancerChore.cancel(true); - } - if (this.normalizerChore != null) { - this.normalizerChore.cancel(true); - } - if (this.clusterStatusChore != null) { - this.clusterStatusChore.cancel(true); - } - if (this.catalogJanitorChore != null) { - this.catalogJanitorChore.cancel(true); - } - if (this.clusterStatusPublisherChore != null){ - clusterStatusPublisherChore.cancel(true); - } - if (this.periodicDoMetricsChore != null) { - periodicDoMetricsChore.cancel(); + ChoreService choreService = getChoreService(); + if (choreService != null) { + choreService.cancelChore(this.balancerChore); + choreService.cancelChore(this.normalizerChore); + choreService.cancelChore(this.clusterStatusChore); + choreService.cancelChore(this.catalogJanitorChore); + choreService.cancelChore(this.clusterStatusPublisherChore); + choreService.cancelChore(this.periodicDoMetricsChore); + choreService.cancelChore(this.logCleaner); + choreService.cancelChore(this.hfileCleaner); + choreService.cancelChore(this.replicationZKLockCleanerChore); + choreService.cancelChore(this.replicationZKNodeCleanerChore); } } 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 8512c2f2985..6c326439875 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 @@ -1064,10 +1064,6 @@ public class HRegionServer extends HasThread implements if (this.hMemManager != null) this.hMemManager.stop(); if (this.cacheFlusher != null) this.cacheFlusher.interruptIfNecessary(); if (this.compactSplitThread != null) this.compactSplitThread.interruptIfNecessary(); - if (this.compactionChecker != null) this.compactionChecker.cancel(true); - if (this.healthCheckChore != null) this.healthCheckChore.cancel(true); - if (this.nonceManagerChore != null) this.nonceManagerChore.cancel(true); - if (this.storefileRefresher != null) this.storefileRefresher.cancel(true); sendShutdownInterrupt(); // Stop the quota manager @@ -2247,13 +2243,16 @@ public class HRegionServer extends HasThread implements */ protected void stopServiceThreads() { // clean up the scheduled chores - if (this.choreService != null) choreService.shutdown(); - if (this.nonceManagerChore != null) nonceManagerChore.cancel(true); - if (this.compactionChecker != null) compactionChecker.cancel(true); - if (this.periodicFlusher != null) periodicFlusher.cancel(true); - if (this.healthCheckChore != null) healthCheckChore.cancel(true); - if (this.storefileRefresher != null) storefileRefresher.cancel(true); - if (this.movedRegionsCleaner != null) movedRegionsCleaner.cancel(true); + if (this.choreService != null) { + choreService.cancelChore(nonceManagerChore); + choreService.cancelChore(compactionChecker); + choreService.cancelChore(periodicFlusher); + choreService.cancelChore(healthCheckChore); + choreService.cancelChore(storefileRefresher); + choreService.cancelChore(movedRegionsCleaner); + // clean up the remaining scheduled chores (in case we missed out any) + choreService.shutdown(); + } if (this.cacheFlusher != null) { this.cacheFlusher.join();