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 bb3ca8ed12
commit 540266a7a0
1 changed files with 9 additions and 7 deletions

View File

@ -613,14 +613,16 @@ public class RegionStates {
// Offline all regions on this server not already in transition. // Offline all regions on this server not already in transition.
List<HRegionInfo> rits = new ArrayList<HRegionInfo>(); List<HRegionInfo> rits = new ArrayList<HRegionInfo>();
Set<HRegionInfo> regionsToCleanIfNoMetaEntry = new HashSet<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) { synchronized (this) {
Set<HRegionInfo> assignedRegions = serverHoldings.get(sn); Set<HRegionInfo> assignedRegions = serverHoldings.get(sn);
if (assignedRegions == null) { if (assignedRegions == null) {
assignedRegions = new HashSet<HRegionInfo>(); assignedRegions = new HashSet<HRegionInfo>();
} }
// Offline regions outside the loop to avoid ConcurrentModificationException
Set<HRegionInfo> regionsToOffline = new HashSet<HRegionInfo>();
for (HRegionInfo region : assignedRegions) { for (HRegionInfo region : assignedRegions) {
// Offline open regions, no need to offline if SPLIT/MERGED/OFFLINE // Offline open regions, no need to offline if SPLIT/MERGED/OFFLINE
if (isRegionOnline(region)) { if (isRegionOnline(region)) {
@ -662,13 +664,13 @@ public class RegionStates {
} }
} }
} }
for (HRegionInfo hri : regionsToOffline) {
regionOffline(hri);
}
this.notifyAll(); this.notifyAll();
} }
for (HRegionInfo hri : regionsToOffline) {
regionOffline(hri);
}
cleanIfNoMetaEntry(regionsToCleanIfNoMetaEntry); cleanIfNoMetaEntry(regionsToCleanIfNoMetaEntry);
return rits; return rits;
} }