diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java index 2ffe466..1e12f41 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java @@ -1657,9 +1657,14 @@ public class AssignmentManager { List regionsNotRecordedInMeta = new ArrayList(); for (HRegionInfo hri : regionsRecordedInMeta) { TableName table = hri.getTable(); - HTableDescriptor htd = master.getTableDescriptors().get(table); - // look at the HTD for the replica count. That's the source of truth - int desiredRegionReplication = htd.getRegionReplication(); + int desiredRegionReplication = 1; + try { + // look at the HTD for the replica count. That's the source of truth + desiredRegionReplication = master.getTableDescriptors().get(table).getRegionReplication(); + } catch (Exception e) { + LOG.warn("Couldn't get the replication attribute of the table " + table + + " due to " + e.getMessage() + ". Try to use hbck to restore table"); + } for (int i = 0; i < desiredRegionReplication; i++) { HRegionInfo replica = RegionReplicaUtil.getRegionInfoForReplica(hri, i); if (regionsRecordedInMeta.contains(replica)) continue; @@ -1702,8 +1707,14 @@ public class AssignmentManager { // maybe because it crashed. PairOfSameType p = MetaTableAccessor.getMergeRegions(result); if (p.getFirst() != null && p.getSecond() != null) { - int numReplicas = ((MasterServices)server).getTableDescriptors().get(p.getFirst(). - getTable()).getRegionReplication(); + int numReplicas = 1; + try { + numReplicas = ((MasterServices) server).getTableDescriptors().get(p.getFirst(). + getTable()).getRegionReplication(); + } catch (Exception e) { + LOG.warn("Couldn't get the replication attribute of the table " + p.getFirst(). + getTable() + " due to " + e.getMessage() + ". Try to use hbck to restore table"); + } for (HRegionInfo merge : p) { for (int i = 1; i < numReplicas; i++) { replicasToClose.add(RegionReplicaUtil.getRegionInfoForReplica(merge, i)); @@ -2649,7 +2660,7 @@ public class AssignmentManager { try { numReplicas = ((MasterServices)server).getTableDescriptors().get(mergedHri.getTable()). getRegionReplication(); - } catch (IOException e) { + } catch (Exception e) { LOG.warn("Couldn't get the replication attribute of the table " + mergedHri.getTable() + " due to " + e.getMessage() + ". The assignment of replicas for the merged region " + "will not be done"); @@ -2678,7 +2689,7 @@ public class AssignmentManager { try { numReplicas = ((MasterServices)server).getTableDescriptors().get(parentHri.getTable()). getRegionReplication(); - } catch (IOException e) { + } catch (Exception e) { LOG.warn("Couldn't get the replication attribute of the table " + parentHri.getTable() + " due to " + e.getMessage() + ". The assignment of daughter replicas " + "replicas will not be done");