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;
|
||||
boolean refresh = false; // for the first time, use cached data
|
||||
RegionServerStatusService.BlockingInterface intf = null;
|
||||
boolean interrupted = false;
|
||||
try {
|
||||
while (keepLooping() && master == null) {
|
||||
sn = this.masterAddressManager.getMasterAddress(refresh);
|
||||
if (sn == null) {
|
||||
|
@ -1976,10 +1978,17 @@ public class HRegionServer implements ClientProtos.ClientService.BlockingInterfa
|
|||
}
|
||||
try {
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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.util.CancelableProgressable;
|
||||
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.zookeeper.ZKSplitLog;
|
||||
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);
|
||||
}
|
||||
if (res == -1) {
|
||||
try {
|
||||
LOG.info(watcher.splitLogZNode + " znode does not exist, waiting for master to create");
|
||||
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();
|
||||
}
|
||||
} 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
|
||||
// to make debugging easier
|
||||
LOG.error("unexpected error ", t);
|
||||
}
|
||||
} finally {
|
||||
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
|
||||
* try to grab every task that has been put up
|
||||
*/
|
||||
private void taskLoop() {
|
||||
private void taskLoop() throws InterruptedException {
|
||||
while (!exitWorker) {
|
||||
int seq_start = taskReadySeq;
|
||||
List<String> paths = getTaskList();
|
||||
|
@ -259,7 +257,6 @@ public class SplitLogWorker extends ZooKeeperListener implements Runnable {
|
|||
SplitLogCounters.tot_wkr_task_grabing.incrementAndGet();
|
||||
synchronized (taskReadyLock) {
|
||||
while (seq_start == taskReadySeq) {
|
||||
try {
|
||||
taskReadyLock.wait(checkInterval);
|
||||
if (this.server != null) {
|
||||
// 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;
|
||||
long sleepTime = 1000;
|
||||
// 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 "
|
||||
+ this.watcher.splitLogZNode, e);
|
||||
}
|
||||
try {
|
||||
LOG.debug("Retry listChildren of znode " + this.watcher.splitLogZNode
|
||||
+ " after sleep for " + sleepTime + "ms!");
|
||||
Thread.sleep(sleepTime);
|
||||
} catch (InterruptedException e1) {
|
||||
LOG.warn("Interrupted while trying to get task list ...", e1);
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
return childrenPaths;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue