HBASE-13326 Disabled table can't be enabled after HBase is restarted

This commit is contained in:
Andrey Stepachev 2015-03-25 22:57:37 +00:00
parent 46e782927d
commit 9df1c244a0
2 changed files with 28 additions and 1 deletions

View File

@ -2893,6 +2893,13 @@ public class AssignmentManager extends ZooKeeperListener {
}
ServerName lastHost = hrl.getServerName();
ServerName regionLocation = RegionStateStore.getRegionServer(result, replicaId);
if (tableStateManager.isTableState(regionInfo.getTable(),
ZooKeeperProtos.Table.State.DISABLED)) {
// force region to forget it hosts for disabled/disabling tables.
// see HBASE-13326
lastHost = null;
regionLocation = null;
}
regionStates.createRegionState(regionInfo, state, regionLocation, lastHost);
if (!regionStates.isRegionInState(regionInfo, State.OPEN)) {
// Region is not open (either offline or in transition), skip

View File

@ -30,7 +30,6 @@ import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.MetaTableAccessor;
import org.apache.hadoop.hbase.MiniHBaseCluster;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Delete;
@ -112,6 +111,27 @@ public class TestEnableTableHandler {
assertEquals(tableName, onlineRegions.get(1).getTable());
}
@Test(timeout = 300000)
public void testDisableTableAndRestart() throws Exception {
final TableName tableName = TableName.valueOf("testDisableTableAndRestart");
final MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
final HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
final HTableDescriptor desc = new HTableDescriptor(tableName);
desc.addFamily(new HColumnDescriptor(FAMILYNAME));
admin.createTable(desc);
admin.disableTable(tableName);
TEST_UTIL.waitTableDisabled(tableName.getName());
TEST_UTIL.getHBaseCluster().shutdown();
TEST_UTIL.getHBaseCluster().waitUntilShutDown();
TEST_UTIL.restartHBaseCluster(2);
admin.enableTable(tableName);
TEST_UTIL.waitTableEnabled(tableName);
}
/**
* We were only clearing rows that had a hregioninfo column in hbase:meta. Mangled rows that
* were missing the hregioninfo because of error were being left behind messing up any