HBASE-17381 ReplicationSourceWorkerThread can die due to unhandled exceptions (huzheng)

Signed-off-by: Gary Helmling <garyh@apache.org>
This commit is contained in:
huzheng 2017-02-06 11:20:11 +08:00 committed by Gary Helmling
parent c55fce00f3
commit d8f3c6cff9
2 changed files with 8 additions and 1 deletions

View File

@ -1334,6 +1334,10 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
*/
@Override
public boolean checkOOME(final Throwable e) {
return exitIfOOME(e);
}
public static boolean exitIfOOME(final Throwable e ){
boolean stop = false;
try {
if (e instanceof OutOfMemoryError
@ -1341,7 +1345,7 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
|| (e.getMessage() != null && e.getMessage().contains(
"java.lang.OutOfMemoryError"))) {
stop = true;
LOG.fatal("Run out of memory; " + getClass().getSimpleName()
LOG.fatal("Run out of memory; " + RSRpcServices.class.getSimpleName()
+ " will abort itself immediately", e);
}
} finally {

View File

@ -53,6 +53,7 @@ import org.apache.hadoop.hbase.MetaTableAccessor;
import org.apache.hadoop.hbase.Stoppable;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.hbase.regionserver.RSRpcServices;
import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
import org.apache.hadoop.hbase.replication.ChainWALEntryFilter;
import org.apache.hadoop.hbase.replication.ClusterMarkingEntryFilter;
@ -778,8 +779,10 @@ public class ReplicationSource extends Thread implements ReplicationSourceInterf
Thread.UncaughtExceptionHandler handler = new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(final Thread t, final Throwable e) {
RSRpcServices.exitIfOOME(e);
LOG.error("Unexpected exception in ReplicationSourceWorkerThread," + " currentPath="
+ getCurrentPath(), e);
stopper.stop("Unexpected exception in ReplicationSourceWorkerThread");
}
};
Threads.setDaemonThreadRunning(this, n + ".replicationSource." + walGroupId + ","