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 34a6c13924..97c9bc33f9 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 @@ -315,6 +315,12 @@ public class HRegionServer extends HasThread implements // Go down hard. Used if file system becomes unavailable and also in // debugging and unit tests. private volatile boolean abortRequested; + + // Only report the abort to master, and log it, once. + // Otherwise logs get polluted with confusing messages. + private final Object abortReportLock = new Object(); + + public static final String ABORT_TIMEOUT = "hbase.regionserver.abort.timeout"; // Default abort timeout is 1200 seconds for safe private static final long DEFAULT_ABORT_TIMEOUT = 1200000; @@ -2396,13 +2402,30 @@ public class HRegionServer extends HasThread implements */ @Override public void abort(String reason, Throwable cause) { + // Once abortRequested is set to true, it's never unset, so this pattern is safe; + // there can be a stale "false", but there can never be a stale "true". + if (!abortRequested) { + synchronized (abortReportLock) { + if (!abortRequested) { + abortRequested = true; + reportAborted(reason, cause); + } + } + } + + // TODO: should we call stop multiple times? its own check is not thread safe. + // shutdown should be run as the internal user + stop(reason, true, null); + } + + /** Log various messages and report to master that we are going to die. */ + private void reportAborted(String reason, Throwable cause) { String msg = "***** ABORTING region server " + this + ": " + reason + " *****"; if (cause != null) { LOG.error(HBaseMarkers.FATAL, msg, cause); } else { LOG.error(HBaseMarkers.FATAL, msg); } - this.abortRequested = true; // HBASE-4014: show list of coprocessors that were loaded to help debug // regionserver crashes.Note that we're implicitly using // java.util.HashSet's toString() method to print the coprocessor names. @@ -2431,8 +2454,6 @@ public class HRegionServer extends HasThread implements } catch (Throwable t) { LOG.warn("Unable to report fatal error to master", t); } - // shutdown should be run as the internal user - stop(reason, true, null); } /**