Index: main/java/org/apache/hadoop/hbase/master/AssignmentManager.java =================================================================== --- main/java/org/apache/hadoop/hbase/master/AssignmentManager.java (revision 1143249) +++ main/java/org/apache/hadoop/hbase/master/AssignmentManager.java (working copy) @@ -1175,6 +1175,32 @@ } /** + * remove RegionState from RegionsInTransition. + *
+ * + * @param encodedName + * @param stamp the stamp of removing RegionState + */ + void removeRegionStateFromRIT(String encodedName, long stamp) + { + if (stamp == -1) return; + + RegionState state; + synchronized (regionsInTransition) { + state = regionsInTransition.get(encodedName); + if (stamp == state.getStamp() + &&(state.getState() == RegionState.State.PENDING_CLOSE)) { + regionsInTransition.remove(encodedName); + LOG.info("Remove RegionState for " + + encodedName + " , stamp= " + stamp + ", PENDING_CLOSE"); + } else { + LOG.info("Unable remove RegionState for " + encodedName + + " , stamp= " + stamp + " because state to " + state.getState()); + } + } + } + + /** * Unassigns the specified region. *
* Updates the RegionState and sends the CLOSE RPC. @@ -1199,10 +1225,12 @@ String encodedName = region.getEncodedName(); // Grab the state of this region and synchronize on it RegionState state; + long stamp = -1; synchronized (regionsInTransition) { state = regionsInTransition.get(encodedName); if (state == null) { state = new RegionState(region, RegionState.State.PENDING_CLOSE); + stamp =state.getStamp(); regionsInTransition.put(encodedName, state); } else if (force && state.isPendingClose()) { LOG.debug("Attempting to unassign region " + @@ -1233,6 +1261,7 @@ } catch (NotServingRegionException nsre) { LOG.info("Server " + server + " returned " + nsre + " for " + region.getEncodedName()); + removeRegionStateFromRIT(encodedName, stamp); // Presume that master has stale data. Presume remote side just split. // Presume that the split message when it comes in will fix up the master's // in memory cluster state. @@ -1241,6 +1270,7 @@ if (t instanceof RemoteException) { t = ((RemoteException)t).unwrapRemoteException(); } + removeRegionStateFromRIT(encodedName, stamp); LOG.info("Server " + server + " returned " + t + " for " + region.getEncodedName()); // Presume retry or server will expire.