/** * This creates a table and then corrupts an hfile. Hbck should quarantine the file. */ @Test(timeout=180000) public void testQuarantineCorruptHFile() throws Exception { TableName table = TableName.valueOf(name.getMethodName()); try { setupTable(table); assertEquals(ROWKEYS.length, countRows()); admin.flush(table); // flush is async. FileSystem fs = FileSystem.get(conf); Path hfile = getFlushedHFile(fs, table); // Mess it up by leaving a hole in the assignment, meta, and hdfs data admin.disableTable(table); // create new corrupt file called deadbeef (valid hfile name) Path corrupt = new Path(hfile.getParent(), "deadbeef"); TestHFile.truncateFile(fs, hfile, corrupt); LOG.info("Created corrupted file " + corrupt); HBaseFsck.debugLsr(conf, FSUtils.getRootDir(conf)); // we cannot enable here because enable never finished due to the corrupt region. HBaseFsck res = HbckTestingUtil.doHFileQuarantine(conf, table); assertEquals(res.getRetCode(), 0); HFileCorruptionChecker hfcc = res.getHFilecorruptionChecker(); assertEquals(hfcc.getHFilesChecked(), 5); assertEquals(hfcc.getCorrupted().size(), 1); assertEquals(hfcc.getFailures().size(), 0); assertEquals(hfcc.getQuarantined().size(), 1); assertEquals(hfcc.getMissing().size(), 0); // Its been fixed, verify that we can enable. admin.enableTable(table); } finally { cleanupTable(table); } }
/** * This creates a table and then corrupts an hfile. Hbck should quarantine the file. */ @Test(timeout=180000) public void testQuarantineCorruptHFile() throws Exception { String table = name.getMethodName(); try { setupTable(table); assertEquals(ROWKEYS.length, countRows()); TEST_UTIL.getHBaseAdmin().flush(table); // flush is async. FileSystem fs = FileSystem.get(conf); Path hfile = getFlushedHFile(fs, table); // Mess it up by leaving a hole in the assignment, meta, and hdfs data TEST_UTIL.getHBaseAdmin().disableTable(table); // create new corrupt file called deadbeef (valid hfile name) Path corrupt = new Path(hfile.getParent(), "deadbeef"); TestHFile.truncateFile(fs, hfile, corrupt); LOG.info("Created corrupted file " + corrupt); HBaseFsck.debugLsr(conf, FSUtils.getRootDir(conf)); // we cannot enable here because enable never finished due to the corrupt region. HBaseFsck res = HbckTestingUtil.doHFileQuarantine(conf, table); assertEquals(res.getRetCode(), 0); HFileCorruptionChecker hfcc = res.getHFilecorruptionChecker(); assertEquals(hfcc.getHFilesChecked(), 5); assertEquals(hfcc.getCorrupted().size(), 1); assertEquals(hfcc.getFailures().size(), 0); assertEquals(hfcc.getQuarantined().size(), 1); assertEquals(hfcc.getMissing().size(), 0); // Its been fixed, verify that we can enable. TEST_UTIL.getHBaseAdmin().enableTable(table); } finally { deleteTable(table); } }
/** * This creates a table and then corrupts an hfile. Hbck should quarantine the file. */ @Test(timeout=180000) public void testQuarantineCorruptHFile() throws Exception { TableName table = TableName.valueOf(name.getMethodName()); try { setupTable(table); assertEquals(ROWKEYS.length, countRows()); TEST_UTIL.getHBaseAdmin().flush(table.getName()); // flush is async. FileSystem fs = FileSystem.get(conf); Path hfile = getFlushedHFile(fs, table); // Mess it up by leaving a hole in the assignment, meta, and hdfs data TEST_UTIL.getHBaseAdmin().disableTable(table); // create new corrupt file called deadbeef (valid hfile name) Path corrupt = new Path(hfile.getParent(), "deadbeef"); TestHFile.truncateFile(fs, hfile, corrupt); LOG.info("Created corrupted file " + corrupt); HBaseFsck.debugLsr(conf, FSUtils.getRootDir(conf)); // we cannot enable here because enable never finished due to the corrupt region. HBaseFsck res = HbckTestingUtil.doHFileQuarantine(conf, table); assertEquals(res.getRetCode(), 0); HFileCorruptionChecker hfcc = res.getHFilecorruptionChecker(); assertEquals(hfcc.getHFilesChecked(), 5); assertEquals(hfcc.getCorrupted().size(), 1); assertEquals(hfcc.getFailures().size(), 0); assertEquals(hfcc.getQuarantined().size(), 1); assertEquals(hfcc.getMissing().size(), 0); // Its been fixed, verify that we can enable. TEST_UTIL.getHBaseAdmin().enableTable(table); } finally { deleteTable(table); } }
private void createRecordAndCorruptMobFile(TableName tn, byte[] row, byte[] family, byte[] qf, byte[] value) throws IOException { Put put1 = new Put(row); put1.addColumn(family, qf, value); table.put(put1); admin.flush(tn); Path mobFile = getFlushedMobFile(conf, fs, tn, Bytes.toString(family)); Assert.assertNotNull(mobFile); // create new corrupt mob file. Path corruptFile = new Path(mobFile.getParent(), "dummy"); TestHFile.truncateFile(fs, mobFile, corruptFile); fs.delete(mobFile, true); fs.rename(corruptFile, mobFile); }
/** * This creates a table and then corrupts an hfile. Hbck should quarantine the file. */ @Test(timeout=120000) public void testQuarantineCorruptHFile() throws Exception { String table = name.getMethodName(); try { setupTable(table); assertEquals(ROWKEYS.length, countRows()); TEST_UTIL.getHBaseAdmin().flush(table); // flush is async. FileSystem fs = FileSystem.get(conf); Path hfile = getFlushedHFile(fs, table); // Mess it up by leaving a hole in the assignment, meta, and hdfs data TEST_UTIL.getHBaseAdmin().disableTable(table); // create new corrupt file called deadbeef (valid hfile name) Path corrupt = new Path(hfile.getParent(), "deadbeef"); TestHFile.truncateFile(fs, hfile, corrupt); LOG.info("Created corrupted file " + corrupt); HBaseFsck.debugLsr(conf, FSUtils.getRootDir(conf)); // we cannot enable here because enable never finished due to the corrupt region. HBaseFsck res = HbckTestingUtil.doHFileQuarantine(conf, table); assertEquals(res.getRetCode(), 0); HFileCorruptionChecker hfcc = res.getHFilecorruptionChecker(); assertEquals(hfcc.getHFilesChecked(), 5); assertEquals(hfcc.getCorrupted().size(), 1); assertEquals(hfcc.getFailures().size(), 0); assertEquals(hfcc.getQuarantined().size(), 1); assertEquals(hfcc.getMissing().size(), 0); // Its been fixed, verify that we can enable. TEST_UTIL.getHBaseAdmin().enableTable(table); } finally { deleteTable(table); } }
/** * This creates a table and then corrupts a mob file. Hbck should quarantine the file. */ @Test(timeout=180000) public void testQuarantineCorruptMobFile() throws Exception { TableName table = TableName.valueOf(name.getMethodName()); try { setupMobTable(table); assertEquals(ROWKEYS.length, countRows()); admin.flush(table); FileSystem fs = FileSystem.get(conf); Path mobFile = getFlushedMobFile(fs, table); admin.disableTable(table); // create new corrupt mob file. String corruptMobFile = createMobFileName(mobFile.getName()); Path corrupt = new Path(mobFile.getParent(), corruptMobFile); TestHFile.truncateFile(fs, mobFile, corrupt); LOG.info("Created corrupted mob file " + corrupt); HBaseFsck.debugLsr(conf, FSUtils.getRootDir(conf)); HBaseFsck.debugLsr(conf, MobUtils.getMobHome(conf)); // A corrupt mob file doesn't abort the start of regions, so we can enable the table. admin.enableTable(table); HBaseFsck res = HbckTestingUtil.doHFileQuarantine(conf, table); assertEquals(0, res.getRetCode()); HFileCorruptionChecker hfcc = res.getHFilecorruptionChecker(); assertEquals(4, hfcc.getHFilesChecked()); assertEquals(0, hfcc.getCorrupted().size()); assertEquals(0, hfcc.getFailures().size()); assertEquals(0, hfcc.getQuarantined().size()); assertEquals(0, hfcc.getMissing().size()); assertEquals(5, hfcc.getMobFilesChecked()); assertEquals(1, hfcc.getCorruptedMobFiles().size()); assertEquals(0, hfcc.getFailureMobFiles().size()); assertEquals(1, hfcc.getQuarantinedMobFiles().size()); assertEquals(0, hfcc.getMissedMobFiles().size()); String quarantinedMobFile = hfcc.getQuarantinedMobFiles().iterator().next().getName(); assertEquals(corruptMobFile, quarantinedMobFile); } finally { cleanupTable(table); } }