HBASE-4907 NPE of MobUtils.hasMobColumns in Build failed in Jenkins: HBase-Trunk_matrix » latest1.8,Hadoop #513 (Jingcheng Du)
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/03e4712f Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/03e4712f Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/03e4712f Branch: refs/heads/hbase-12439 Commit: 03e4712f0ca08d57586b3fc4d93cf02c999515d8 Parents: 8b3d1f1 Author: stack <st...@apache.org> Authored: Fri Dec 4 10:53:09 2015 -0800 Committer: stack <st...@apache.org> Committed: Fri Dec 4 10:53:09 2015 -0800 ---------------------------------------------------------------------- .../master/procedure/DeleteTableProcedure.java | 23 +++----- .../procedure/TestCreateTableProcedure.java | 58 ++++++++++++-------- 2 files changed, 42 insertions(+), 39 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/03e4712f/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/DeleteTableProcedure.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/DeleteTableProcedure.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/DeleteTableProcedure.java index 4b95fa8..1e86254 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/DeleteTableProcedure.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/DeleteTableProcedure.java @@ -31,7 +31,6 @@ import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.hadoop.hbase.HRegionInfo; -import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.MetaTableAccessor; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.TableNotDisabledException; @@ -345,19 +344,13 @@ public class DeleteTableProcedure LOG.debug("Table '" + tableName + "' archived!"); } - // Archive the mob data if there is a mob-enabled column - HTableDescriptor htd = env.getMasterServices().getTableDescriptors().get(tableName); - boolean hasMob = MobUtils.hasMobColumns(htd); - Path mobTableDir = null; - if (hasMob) { - // Archive mob data - mobTableDir = FSUtils.getTableDir(new Path(mfs.getRootDir(), MobConstants.MOB_DIR_NAME), - tableName); - Path regionDir = - new Path(mobTableDir, MobUtils.getMobRegionInfo(tableName).getEncodedName()); - if (fs.exists(regionDir)) { - HFileArchiver.archiveRegion(fs, mfs.getRootDir(), mobTableDir, regionDir); - } + // Archive mob data + Path mobTableDir = FSUtils.getTableDir(new Path(mfs.getRootDir(), MobConstants.MOB_DIR_NAME), + tableName); + Path regionDir = + new Path(mobTableDir, MobUtils.getMobRegionInfo(tableName).getEncodedName()); + if (fs.exists(regionDir)) { + HFileArchiver.archiveRegion(fs, mfs.getRootDir(), mobTableDir, regionDir); } // Delete table directory from FS (temp directory) @@ -366,7 +359,7 @@ public class DeleteTableProcedure } // Delete the table directory where the mob files are saved - if (hasMob && mobTableDir != null && fs.exists(mobTableDir)) { + if (mobTableDir != null && fs.exists(mobTableDir)) { if (!fs.delete(mobTableDir, true)) { throw new IOException("Couldn't delete mob dir " + mobTableDir); } http://git-wip-us.apache.org/repos/asf/hbase/blob/03e4712f/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestCreateTableProcedure.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestCreateTableProcedure.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestCreateTableProcedure.java index 0aad5fa..676a3f4 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestCreateTableProcedure.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/procedure/TestCreateTableProcedure.java @@ -195,32 +195,15 @@ public class TestCreateTableProcedure { @Test(timeout=90000) public void testRollbackAndDoubleExecution() throws Exception { final TableName tableName = TableName.valueOf("testRollbackAndDoubleExecution"); + testRollbackAndDoubleExecution(MasterProcedureTestingUtility.createHTD(tableName, "f1", "f2")); + } - // create the table - final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor(); - ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExec, true); - - // Start the Create procedure && kill the executor - final byte[][] splitKeys = new byte[][] { - Bytes.toBytes("a"), Bytes.toBytes("b"), Bytes.toBytes("c") - }; + @Test(timeout=90000) + public void testRollbackAndDoubleExecutionOnMobTable() throws Exception { + final TableName tableName = TableName.valueOf("testRollbackAndDoubleExecutionOnMobTable"); HTableDescriptor htd = MasterProcedureTestingUtility.createHTD(tableName, "f1", "f2"); - htd.setRegionReplication(3); - HRegionInfo[] regions = ModifyRegionUtils.createHRegionInfos(htd, splitKeys); - long procId = procExec.submitProcedure( - new CreateTableProcedure(procExec.getEnvironment(), htd, regions), nonceGroup, nonce); - - // NOTE: the 4 (number of CreateTableState steps) is hardcoded, - // so you have to look at this test at least once when you add a new step. - MasterProcedureTestingUtility.testRollbackAndDoubleExecution( - procExec, procId, 4, CreateTableState.values()); - - MasterProcedureTestingUtility.validateTableDeletion( - UTIL.getHBaseCluster().getMaster(), tableName, regions, "f1", "f2"); - - // are we able to create the table after a rollback? - resetProcExecutorTestingKillFlag(); - testSimpleCreate(tableName, splitKeys); + htd.getFamily(Bytes.toBytes("f1")).setMobEnabled(true); + testRollbackAndDoubleExecution(htd); } @Test(timeout=90000) @@ -282,4 +265,31 @@ public class TestCreateTableProcedure { } } } + + private void testRollbackAndDoubleExecution(HTableDescriptor htd) throws Exception { + // create the table + final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor(); + ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExec, true); + + // Start the Create procedure && kill the executor + final byte[][] splitKeys = new byte[][] { + Bytes.toBytes("a"), Bytes.toBytes("b"), Bytes.toBytes("c") + }; + htd.setRegionReplication(3); + HRegionInfo[] regions = ModifyRegionUtils.createHRegionInfos(htd, splitKeys); + long procId = procExec.submitProcedure( + new CreateTableProcedure(procExec.getEnvironment(), htd, regions), nonceGroup, nonce); + + // NOTE: the 4 (number of CreateTableState steps) is hardcoded, + // so you have to look at this test at least once when you add a new step. + MasterProcedureTestingUtility.testRollbackAndDoubleExecution( + procExec, procId, 4, CreateTableState.values()); + TableName tableName = htd.getTableName(); + MasterProcedureTestingUtility.validateTableDeletion( + UTIL.getHBaseCluster().getMaster(), tableName, regions, "f1", "f2"); + + // are we able to create the table after a rollback? + resetProcExecutorTestingKillFlag(); + testSimpleCreate(tableName, splitKeys); + } }