HBASE-13083 Master can be dead-locked while assigning META. (Andrey Stepachev)

This commit is contained in:
stack 2015-02-23 21:17:01 -08:00
parent b20675f5af
commit 4a74f5e829
1 changed files with 9 additions and 7 deletions

View File

@ -576,14 +576,16 @@ public class RegionStates {
// Offline all regions on this server not already in transition.
List<HRegionInfo> rits = new ArrayList<HRegionInfo>();
Set<HRegionInfo> regionsToCleanIfNoMetaEntry = new HashSet<HRegionInfo>();
// Offline regions outside the loop and synchronized block to avoid
// ConcurrentModificationException and deadlock in case of meta anassigned,
// but RegionState a blocked.
Set<HRegionInfo> regionsToOffline = new HashSet<HRegionInfo>();
synchronized (this) {
Set<HRegionInfo> assignedRegions = serverHoldings.get(sn);
if (assignedRegions == null) {
assignedRegions = new HashSet<HRegionInfo>();
}
// Offline regions outside the loop to avoid ConcurrentModificationException
Set<HRegionInfo> regionsToOffline = new HashSet<HRegionInfo>();
for (HRegionInfo region : assignedRegions) {
// Offline open regions, no need to offline if SPLIT/MERGED/OFFLINE
if (isRegionOnline(region)) {
@ -620,13 +622,13 @@ public class RegionStates {
}
}
}
for (HRegionInfo hri : regionsToOffline) {
regionOffline(hri);
}
this.notifyAll();
}
for (HRegionInfo hri : regionsToOffline) {
regionOffline(hri);
}
cleanIfNoMetaEntry(regionsToCleanIfNoMetaEntry);
return rits;
}