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:
Josh Elser 2020-06-15 21:15:38 -04:00
parent 4dd59a0635
commit 404c2dd3fe
1 changed files with 9 additions and 5 deletions

View File

@ -3220,12 +3220,16 @@ public class AssignmentManager extends ZooKeeperListener {
// maybe because it crashed.
PairOfSameType<HRegionInfo> p = MetaTableAccessor.getMergeRegions(result);
if (p.getFirst() != null && p.getSecond() != null) {
int numReplicas = server.getTableDescriptors().get(p.getFirst().
getTable()).getRegionReplication();
for (HRegionInfo merge : p) {
for (int i = 1; i < numReplicas; i++) {
replicasToClose.add(RegionReplicaUtil.getRegionInfoForReplica(merge, i));
HTableDescriptor desc = server.getTableDescriptors().get(p.getFirst().getTable());
if (desc != null) {
int numReplicas = desc.getRegionReplication();
for (HRegionInfo merge : p) {
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);