HBASE-19365 Guard against a missing table descriptor which crashes master
While we never expect table descriptors to be missing, a corrupt meta can result in the master crashing before regions get assigned. We can guard against that happening with a simple null-check. Signed-off-by: Viraj Jasani <vjasani@apache.org> Closes #1908
This commit is contained in:
parent
4dd59a0635
commit
404c2dd3fe
|
@ -3220,12 +3220,16 @@ public class AssignmentManager extends ZooKeeperListener {
|
||||||
// maybe because it crashed.
|
// maybe because it crashed.
|
||||||
PairOfSameType<HRegionInfo> p = MetaTableAccessor.getMergeRegions(result);
|
PairOfSameType<HRegionInfo> p = MetaTableAccessor.getMergeRegions(result);
|
||||||
if (p.getFirst() != null && p.getSecond() != null) {
|
if (p.getFirst() != null && p.getSecond() != null) {
|
||||||
int numReplicas = server.getTableDescriptors().get(p.getFirst().
|
HTableDescriptor desc = server.getTableDescriptors().get(p.getFirst().getTable());
|
||||||
getTable()).getRegionReplication();
|
if (desc != null) {
|
||||||
for (HRegionInfo merge : p) {
|
int numReplicas = desc.getRegionReplication();
|
||||||
for (int i = 1; i < numReplicas; i++) {
|
for (HRegionInfo merge : p) {
|
||||||
replicasToClose.add(RegionReplicaUtil.getRegionInfoForReplica(merge, i));
|
for (int i = 1; i < numReplicas; i++) {
|
||||||
|
replicasToClose.add(RegionReplicaUtil.getRegionInfoForReplica(merge, i));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
LOG.warn("Found no table descriptor on filesystem for " + p.getFirst().getTable());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RegionLocations rl = MetaTableAccessor.getRegionLocations(result);
|
RegionLocations rl = MetaTableAccessor.getRegionLocations(result);
|
||||||
|
|
Loading…
Reference in New Issue