HBASE-21297 ModifyTableProcedure can throw TNDE instead of IOE in case of REGION_REPLICATION change

Signed-off-by: Guanghao Zhang <zghao@apache.org>
This commit is contained in:
Nihal Jain 2018-10-25 22:34:17 +05:30 committed by Guanghao Zhang
parent f59b99c48a
commit d394d84420
2 changed files with 23 additions and 1 deletions

View File

@ -27,6 +27,7 @@ import org.apache.hadoop.hbase.HBaseIOException;
import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.MetaTableAccessor; import org.apache.hadoop.hbase.MetaTableAccessor;
import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.TableNotDisabledException;
import org.apache.hadoop.hbase.TableNotFoundException; import org.apache.hadoop.hbase.TableNotFoundException;
import org.apache.hadoop.hbase.client.Connection; import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.RegionInfo; import org.apache.hadoop.hbase.client.RegionInfo;
@ -249,7 +250,8 @@ public class ModifyTableProcedure
.isTableState(getTableName(), TableState.State.ENABLED)) { .isTableState(getTableName(), TableState.State.ENABLED)) {
if (modifiedTableDescriptor.getRegionReplication() != unmodifiedTableDescriptor if (modifiedTableDescriptor.getRegionReplication() != unmodifiedTableDescriptor
.getRegionReplication()) { .getRegionReplication()) {
throw new IOException("REGION_REPLICATION change is not supported for enabled tables"); throw new TableNotDisabledException(
"REGION_REPLICATION change is not supported for enabled tables");
} }
} }

View File

@ -523,6 +523,26 @@ public class TestAdmin1 {
assertFalse(this.admin.tableExists(tableName)); assertFalse(this.admin.tableExists(tableName));
} }
@Test(expected = TableNotDisabledException.class)
public void testModifyRegionReplicasEnabledTable() throws Exception {
final TableName tableName = TableName.valueOf(name.getMethodName());
TEST_UTIL.createTable(tableName, HConstants.CATALOG_FAMILY).close();
// Modify region replication count
TableDescriptor htd = TableDescriptorBuilder.newBuilder(admin.getDescriptor(tableName))
.setRegionReplication(3).build();
try {
// try to modify the region replication count without disabling the table
admin.modifyTable(htd);
fail("Expected an exception");
} finally {
// Delete the table
admin.disableTable(tableName);
admin.deleteTable(tableName);
assertFalse(admin.tableExists(tableName));
}
}
/** /**
* Verify schema modification takes. * Verify schema modification takes.
*/ */