From 971f5350e81591e9360677f3617a399f453b6b96 Mon Sep 17 00:00:00 2001 From: huzheng Date: Fri, 4 May 2018 19:44:10 +0800 Subject: [PATCH] HBASE-20531 RS may throw NPE when close meta regions in shutdown procedure. --- .../hbase/regionserver/HRegionServer.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 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 240de85e778..188aef633bf 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 @@ -1052,15 +1052,6 @@ public class HRegionServer extends HasThread implements if (this.storefileRefresher != null) this.storefileRefresher.cancel(true); sendShutdownInterrupt(); - // Stop the quota manager - if (rsQuotaManager != null) { - rsQuotaManager.stop(); - } - if (rsSpaceQuotaManager != null) { - rsSpaceQuotaManager.stop(); - rsSpaceQuotaManager = null; - } - // Stop the snapshot and other procedure handlers, forcefully killing all running tasks if (rspmHost != null) { rspmHost.stop(this.abortRequested || this.killed); @@ -1106,6 +1097,15 @@ public class HRegionServer extends HasThread implements LOG.info("stopping server " + this.serverName + "; all regions closed."); } + // Stop the quota manager + if (rsQuotaManager != null) { + rsQuotaManager.stop(); + } + if (rsSpaceQuotaManager != null) { + rsSpaceQuotaManager.stop(); + rsSpaceQuotaManager = null; + } + //fsOk flag may be changed when closing regions throws exception. if (this.fsOk) { shutdownWAL(!abortRequested); @@ -3697,9 +3697,9 @@ public class HRegionServer extends HasThread implements @Override public boolean reportFileArchivalForQuotas(TableName tableName, - Collection> archivedFiles) { + Collection> archivedFiles) { RegionServerStatusService.BlockingInterface rss = rssStub; - if (rss == null) { + if (rss == null || rsSpaceQuotaManager == null) { // the current server could be stopping. LOG.trace("Skipping file archival reporting to HMaster as stub is null"); return false;