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 a75e5a5435
commit 8574934f59
2 changed files with 8 additions and 1 deletions

View File

@ -1228,6 +1228,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
@ -1235,7 +1239,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

@ -58,6 +58,7 @@ import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.hbase.protobuf.generated.WALProtos;
import org.apache.hadoop.hbase.protobuf.generated.WALProtos.BulkLoadDescriptor;
import org.apache.hadoop.hbase.protobuf.generated.WALProtos.StoreDescriptor;
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.ReplicationEndpoint;
@ -1289,8 +1290,10 @@ public class ReplicationSource extends Thread
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 + ","