HBASE-10524 Correct wrong handling and add proper handling for swallowed InterruptedException thrown by Thread.sleep in regionserver (Feng Honghua)
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1570219 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
65fa5c4d82
commit
3f485568a9
|
@ -1939,6 +1939,8 @@ public class HRegionServer implements ClientProtos.ClientService.BlockingInterfa
|
||||||
RegionServerStatusService.BlockingInterface master = null;
|
RegionServerStatusService.BlockingInterface master = null;
|
||||||
boolean refresh = false; // for the first time, use cached data
|
boolean refresh = false; // for the first time, use cached data
|
||||||
RegionServerStatusService.BlockingInterface intf = null;
|
RegionServerStatusService.BlockingInterface intf = null;
|
||||||
|
boolean interrupted = false;
|
||||||
|
try {
|
||||||
while (keepLooping() && master == null) {
|
while (keepLooping() && master == null) {
|
||||||
sn = this.masterAddressManager.getMasterAddress(refresh);
|
sn = this.masterAddressManager.getMasterAddress(refresh);
|
||||||
if (sn == null) {
|
if (sn == null) {
|
||||||
|
@ -1976,10 +1978,17 @@ public class HRegionServer implements ClientProtos.ClientService.BlockingInterfa
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Thread.sleep(200);
|
Thread.sleep(200);
|
||||||
} catch (InterruptedException ignored) {
|
} catch (InterruptedException ex) {
|
||||||
|
interrupted = true;
|
||||||
|
LOG.warn("Interrupted while sleeping");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
if (interrupted) {
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
}
|
||||||
|
}
|
||||||
return new Pair<ServerName, RegionServerStatusService.BlockingInterface>(sn, intf);
|
return new Pair<ServerName, RegionServerStatusService.BlockingInterface>(sn, intf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,7 @@ import org.apache.hadoop.hbase.regionserver.wal.HLogSplitter;
|
||||||
import org.apache.hadoop.hbase.regionserver.wal.HLogUtil;
|
import org.apache.hadoop.hbase.regionserver.wal.HLogUtil;
|
||||||
import org.apache.hadoop.hbase.util.CancelableProgressable;
|
import org.apache.hadoop.hbase.util.CancelableProgressable;
|
||||||
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
|
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
|
||||||
|
import org.apache.hadoop.hbase.util.ExceptionUtil;
|
||||||
import org.apache.hadoop.hbase.util.FSUtils;
|
import org.apache.hadoop.hbase.util.FSUtils;
|
||||||
import org.apache.hadoop.hbase.zookeeper.ZKSplitLog;
|
import org.apache.hadoop.hbase.zookeeper.ZKSplitLog;
|
||||||
import org.apache.hadoop.hbase.zookeeper.ZKUtil;
|
import org.apache.hadoop.hbase.zookeeper.ZKUtil;
|
||||||
|
@ -190,16 +191,8 @@ public class SplitLogWorker extends ZooKeeperListener implements Runnable {
|
||||||
LOG.warn("Exception when checking for " + watcher.splitLogZNode + " ... retrying", e);
|
LOG.warn("Exception when checking for " + watcher.splitLogZNode + " ... retrying", e);
|
||||||
}
|
}
|
||||||
if (res == -1) {
|
if (res == -1) {
|
||||||
try {
|
|
||||||
LOG.info(watcher.splitLogZNode + " znode does not exist, waiting for master to create");
|
LOG.info(watcher.splitLogZNode + " znode does not exist, waiting for master to create");
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
} catch (InterruptedException e) {
|
|
||||||
LOG.debug("Interrupted while waiting for " + watcher.splitLogZNode
|
|
||||||
+ (exitWorker ? "" : " (ERROR: exitWorker is not set, " +
|
|
||||||
"exiting anyway)"));
|
|
||||||
exitWorker = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,9 +200,14 @@ public class SplitLogWorker extends ZooKeeperListener implements Runnable {
|
||||||
taskLoop();
|
taskLoop();
|
||||||
}
|
}
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
|
if (ExceptionUtil.isInterrupt(t)) {
|
||||||
|
LOG.info("SplitLogWorker interrupted. Exiting. " + (exitWorker ? "" :
|
||||||
|
" (ERROR: exitWorker is not set, exiting anyway)"));
|
||||||
|
} else {
|
||||||
// only a logical error can cause here. Printing it out
|
// only a logical error can cause here. Printing it out
|
||||||
// to make debugging easier
|
// to make debugging easier
|
||||||
LOG.error("unexpected error ", t);
|
LOG.error("unexpected error ", t);
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
LOG.info("SplitLogWorker " + this.serverName + " exiting");
|
LOG.info("SplitLogWorker " + this.serverName + " exiting");
|
||||||
}
|
}
|
||||||
|
@ -223,7 +221,7 @@ public class SplitLogWorker extends ZooKeeperListener implements Runnable {
|
||||||
* Synchronization using {@link #taskReadyLock} ensures that it will
|
* Synchronization using {@link #taskReadyLock} ensures that it will
|
||||||
* try to grab every task that has been put up
|
* try to grab every task that has been put up
|
||||||
*/
|
*/
|
||||||
private void taskLoop() {
|
private void taskLoop() throws InterruptedException {
|
||||||
while (!exitWorker) {
|
while (!exitWorker) {
|
||||||
int seq_start = taskReadySeq;
|
int seq_start = taskReadySeq;
|
||||||
List<String> paths = getTaskList();
|
List<String> paths = getTaskList();
|
||||||
|
@ -259,7 +257,6 @@ public class SplitLogWorker extends ZooKeeperListener implements Runnable {
|
||||||
SplitLogCounters.tot_wkr_task_grabing.incrementAndGet();
|
SplitLogCounters.tot_wkr_task_grabing.incrementAndGet();
|
||||||
synchronized (taskReadyLock) {
|
synchronized (taskReadyLock) {
|
||||||
while (seq_start == taskReadySeq) {
|
while (seq_start == taskReadySeq) {
|
||||||
try {
|
|
||||||
taskReadyLock.wait(checkInterval);
|
taskReadyLock.wait(checkInterval);
|
||||||
if (this.server != null) {
|
if (this.server != null) {
|
||||||
// check to see if we have stale recovering regions in our internal memory state
|
// check to see if we have stale recovering regions in our internal memory state
|
||||||
|
@ -293,17 +290,9 @@ public class SplitLogWorker extends ZooKeeperListener implements Runnable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (InterruptedException e) {
|
|
||||||
LOG.info("SplitLogWorker interrupted while waiting for task," +
|
|
||||||
" exiting: " + e.toString() + (exitWorker ? "" :
|
|
||||||
" (ERROR: exitWorker is not set, exiting anyway)"));
|
|
||||||
exitWorker = true;
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -559,7 +548,7 @@ public class SplitLogWorker extends ZooKeeperListener implements Runnable {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private List<String> getTaskList() {
|
private List<String> getTaskList() throws InterruptedException {
|
||||||
List<String> childrenPaths = null;
|
List<String> childrenPaths = null;
|
||||||
long sleepTime = 1000;
|
long sleepTime = 1000;
|
||||||
// It will be in loop till it gets the list of children or
|
// It will be in loop till it gets the list of children or
|
||||||
|
@ -575,14 +564,9 @@ public class SplitLogWorker extends ZooKeeperListener implements Runnable {
|
||||||
LOG.warn("Could not get children of znode "
|
LOG.warn("Could not get children of znode "
|
||||||
+ this.watcher.splitLogZNode, e);
|
+ this.watcher.splitLogZNode, e);
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
LOG.debug("Retry listChildren of znode " + this.watcher.splitLogZNode
|
LOG.debug("Retry listChildren of znode " + this.watcher.splitLogZNode
|
||||||
+ " after sleep for " + sleepTime + "ms!");
|
+ " after sleep for " + sleepTime + "ms!");
|
||||||
Thread.sleep(sleepTime);
|
Thread.sleep(sleepTime);
|
||||||
} catch (InterruptedException e1) {
|
|
||||||
LOG.warn("Interrupted while trying to get task list ...", e1);
|
|
||||||
Thread.currentThread().interrupt();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return childrenPaths;
|
return childrenPaths;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue