HBASE-9099: logReplay could trigger double region assignment

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1510615 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
jeffreyz 2013-08-05 17:28:13 +00:00
parent 2036dbb763
commit 96e750fdac
3 changed files with 19 additions and 18 deletions

View File

@ -2776,11 +2776,10 @@ public class AssignmentManager extends ZooKeeperListener {
* @param hri * @param hri
* @param timeOut Milliseconds to wait for current region to be out of transition state. * @param timeOut Milliseconds to wait for current region to be out of transition state.
* @return True when a region clears regions-in-transition before timeout otherwise false * @return True when a region clears regions-in-transition before timeout otherwise false
* @throws IOException
* @throws InterruptedException * @throws InterruptedException
*/ */
public boolean waitOnRegionToClearRegionsInTransition(final HRegionInfo hri, long timeOut) public boolean waitOnRegionToClearRegionsInTransition(final HRegionInfo hri, long timeOut)
throws IOException, InterruptedException { throws InterruptedException {
if (!regionStates.isRegionInTransition(hri)) return true; if (!regionStates.isRegionInTransition(hri)) return true;
RegionState rs = null; RegionState rs = null;
long end = (timeOut <= 0) ? Long.MAX_VALUE : EnvironmentEdgeManager.currentTimeMillis() long end = (timeOut <= 0) ? Long.MAX_VALUE : EnvironmentEdgeManager.currentTimeMillis()

View File

@ -85,7 +85,9 @@ public class MetaServerShutdownHandler extends ServerShutdownHandler {
if (this.shouldSplitHlog && this.distributedLogReplay) { if (this.shouldSplitHlog && this.distributedLogReplay) {
if (!am.waitOnRegionToClearRegionsInTransition(HRegionInfo.FIRST_META_REGIONINFO, if (!am.waitOnRegionToClearRegionsInTransition(HRegionInfo.FIRST_META_REGIONINFO,
regionAssignmentWaitTimeout)) { regionAssignmentWaitTimeout)) {
throw new IOException("Region " + HRegionInfo.FIRST_META_REGIONINFO.getEncodedName() // Wait here is to avoid log replay hits current dead server and incur a RPC timeout
// when replay happens before region assignment completes.
LOG.warn("Region " + HRegionInfo.FIRST_META_REGIONINFO.getEncodedName()
+ " didn't complete assignment in time"); + " didn't complete assignment in time");
} }
this.services.getMasterFileSystem().splitMetaLog(serverName); this.services.getMasterFileSystem().splitMetaLog(serverName);

View File

@ -19,6 +19,7 @@
package org.apache.hadoop.hbase.master.handler; package org.apache.hadoop.hbase.master.handler;
import java.io.IOException; import java.io.IOException;
import java.io.InterruptedIOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@ -278,26 +279,25 @@ public class ServerShutdownHandler extends EventHandler {
throw new IOException(ie); throw new IOException(ie);
} }
try { if (this.shouldSplitHlog && this.distributedLogReplay) {
if (this.shouldSplitHlog && this.distributedLogReplay) { // wait for region assignment completes
// wait for region assignment completes for (HRegionInfo hri : toAssignRegions) {
for (HRegionInfo hri : toAssignRegions) { try {
if (!am.waitOnRegionToClearRegionsInTransition(hri, regionAssignmentWaitTimeout)) { if (!am.waitOnRegionToClearRegionsInTransition(hri, regionAssignmentWaitTimeout)) {
throw new IOException("Region " + hri.getEncodedName() // Wait here is to avoid log replay hits current dead server and incur a RPC timeout
// when replay happens before region assignment completes.
LOG.warn("Region " + hri.getEncodedName()
+ " didn't complete assignment in time"); + " didn't complete assignment in time");
} }
} catch (InterruptedException ie) {
throw new InterruptedIOException("Caught " + ie
+ " during waitOnRegionToClearRegionsInTransition");
} }
// submit logReplay work
this.services.getExecutorService().submit(
new LogReplayHandler(this.server, this.services, this.deadServers, this.serverName));
hasLogReplayWork = true;
}
} catch (Exception ex) {
if (ex instanceof IOException) {
resubmit(serverName, (IOException)ex);
} else {
throw new IOException(ex);
} }
// submit logReplay work
this.services.getExecutorService().submit(
new LogReplayHandler(this.server, this.services, this.deadServers, this.serverName));
hasLogReplayWork = true;
} }
} finally { } finally {
this.deadServers.finish(serverName); this.deadServers.finish(serverName);