HBASE-3263 Stack overflow in AssignmentManager

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1040360 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2010-11-30 00:42:03 +00:00
parent c849b4c26d
commit 1674a7ee41
1 changed files with 31 additions and 45 deletions

View File

@ -96,7 +96,7 @@ public class AssignmentManager extends ZooKeeperListener {
/*
* Maximum times we recurse an assignment. See below in {@link #assign()}.
*/
private final int maximumAssignmentRecursions;
private final int maximumAssignmentAttempts;
/**
* Regions currently in transition. Map of encoded region names to the master
@ -163,8 +163,8 @@ public class AssignmentManager extends ZooKeeperListener {
Threads.setDaemonThreadRunning(timeoutMonitor,
master.getServerName() + ".timeoutMonitor");
this.zkTable = new ZKTable(this.master.getZooKeeper());
this.maximumAssignmentRecursions =
this.master.getConfiguration().getInt("hbase.assignment.maximum.recursions", 10);
this.maximumAssignmentAttempts =
this.master.getConfiguration().getInt("hbase.assignment.maximum.attempts", 10);
}
/**
@ -823,18 +823,7 @@ public class AssignmentManager extends ZooKeeperListener {
*/
private void assign(final RegionState state, final boolean setOfflineInZK,
final boolean forceNewPlan) {
assign(state, setOfflineInZK, forceNewPlan, new AtomicInteger(0));
}
/**
* Caller must hold lock on the passed <code>state</code> object.
* @param state
* @param setOfflineInZK
* @param forceNewPlan
* @param recursions Keep a count so can have upper bound on recursions.
*/
private void assign(final RegionState state, final boolean setOfflineInZK,
final boolean forceNewPlan, final int recursions) {
for (int i = 0; i < this.maximumAssignmentAttempts; i++) {
if (setOfflineInZK && !setOfflineInZooKeeper(state)) return;
if (this.master.isStopped()) {
LOG.debug("Server stopped; skipping assign of " + state);
@ -852,8 +841,8 @@ public class AssignmentManager extends ZooKeeperListener {
} catch (Throwable t) {
LOG.warn("Failed assignment of " +
state.getRegion().getRegionNameAsString() + " to " +
plan.getDestination() + ", trying to assign elsewhere instead; retry=" +
recursions, t);
plan.getDestination() + ", trying to assign elsewhere instead; " +
"retry=" + i, t);
// Clean out plan we failed execute and one that doesn't look like it'll
// succeed anyways; we need a new plan!
// Transition back to OFFLINE
@ -864,10 +853,7 @@ public class AssignmentManager extends ZooKeeperListener {
state.getRegion().getRegionNameAsString());
return;
}
if (recursions < this.maximumAssignmentRecursions) {
assign(state, false, false, recursions + 1);
}
// Else Just leave the region in RIT. On timeout, we'll retry later.
}
}