Index: hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java =================================================================== --- hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java (revision 1382616) +++ hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java (working copy) @@ -470,7 +470,11 @@ String tableName = Bytes.toString(hi.getTableName()); TableInfo tableInfo = tablesInfo.get(tableName); - Preconditions.checkNotNull("Table " + tableName + "' not present!", tableInfo); + if (tableInfo == null) { + LOG.warn("Table '" + tableName + "' not present!"); + LOG.warn("Try to fix table '" + tableName + "' before -fixHdfsOrphans"); + return; + } HTableDescriptor template = tableInfo.getHTD(); // find min and max key values @@ -3467,54 +3471,60 @@ Runtime.getRuntime().exit(-1); } - // do the real work of hbck - connect(); - - // if corrupt file mode is on, first fix them since they may be opened later - if (checkCorruptHFiles || sidelineCorruptHFiles) { - LOG.info("Checking all hfiles for corruption"); - HFileCorruptionChecker hfcc = createHFileCorruptionChecker(sidelineCorruptHFiles); - setHFileCorruptionChecker(hfcc); // so we can get result - Collection tables = getIncludedTables(); - Collection tableDirs = new ArrayList(); - Path rootdir = FSUtils.getRootDir(conf); - if (tables.size() > 0) { - for (String t : tables) { - tableDirs.add(FSUtils.getTablePath(rootdir, t)); + try { + // do the real work of hbck + connect(); + + // if corrupt file mode is on, first fix them since they may be opened later + if (checkCorruptHFiles || sidelineCorruptHFiles) { + LOG.info("Checking all hfiles for corruption"); + HFileCorruptionChecker hfcc = createHFileCorruptionChecker(sidelineCorruptHFiles); + setHFileCorruptionChecker(hfcc); // so we can get result + Collection tables = getIncludedTables(); + Collection tableDirs = new ArrayList(); + Path rootdir = FSUtils.getRootDir(conf); + if (tables.size() > 0) { + for (String t : tables) { + tableDirs.add(FSUtils.getTablePath(rootdir, t)); + } + } else { + tableDirs = FSUtils.getTableDirs(FSUtils.getCurrentFileSystem(conf), rootdir); } - } else { - tableDirs = FSUtils.getTableDirs(FSUtils.getCurrentFileSystem(conf), rootdir); + hfcc.checkTables(tableDirs); + PrintWriter out = new PrintWriter(System.out); + hfcc.report(out); + out.flush(); } - hfcc.checkTables(tableDirs); - PrintWriter out = new PrintWriter(System.out); - hfcc.report(out); - out.flush(); - } - - // check and fix table integrity, region consistency. - int code = onlineHbck(); - setRetCode(code); - // If we have changed the HBase state it is better to run hbck again - // to see if we haven't broken something else in the process. - // We run it only once more because otherwise we can easily fall into - // an infinite loop. - if (shouldRerun()) { - try { - LOG.info("Sleeping " + sleepBeforeRerun + "ms before re-checking after fix..."); - Thread.sleep(sleepBeforeRerun); - } catch (InterruptedException ie) { - return this; + + // check and fix table integrity, region consistency. + int code = onlineHbck(); + setRetCode(code); + // If we have changed the HBase state it is better to run hbck again + // to see if we haven't broken something else in the process. + // We run it only once more because otherwise we can easily fall into + // an infinite loop. + if (shouldRerun()) { + try { + LOG.info("Sleeping " + sleepBeforeRerun + "ms before re-checking after fix..."); + Thread.sleep(sleepBeforeRerun); + } catch (InterruptedException ie) { + return this; + } + // Just report + setFixAssignments(false); + setFixMeta(false); + setFixHdfsHoles(false); + setFixHdfsOverlaps(false); + setFixVersionFile(false); + setFixTableOrphans(false); + errors.resetErrors(); + code = onlineHbck(); + setRetCode(code); } - // Just report - setFixAssignments(false); - setFixMeta(false); - setFixHdfsHoles(false); - setFixHdfsOverlaps(false); - setFixVersionFile(false); - setFixTableOrphans(false); - errors.resetErrors(); - code = onlineHbck(); - setRetCode(code); + } finally { + // To cleanup the incomplete threads in the "finally" block to prevent the + // entire process suspending. + executor.shutdown(); } return this; }