diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java index cae8ce6..deadf0d 100644 --- hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java +++ hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java @@ -1090,29 +1090,13 @@ public class HBaseFsck extends Configured implements Closeable { errors.reportError(ERROR_CODE.LINGERING_REFERENCE_HFILE, "Found lingering reference file " + path); if (!shouldFixReferenceFiles()) continue; - - // Now, trying to fix it since requested - boolean success = false; - String pathStr = path.toString(); + setShouldRerun(); // A reference file path should be like // ${hbase.rootdir}/data/namespace/table_name/region_id/family_name/referred_file.region_name - // Up 5 directories to get the root folder. - // So the file will be sidelined to a similar folder structure. - int index = pathStr.lastIndexOf(Path.SEPARATOR_CHAR); - for (int i = 0; index > 0 && i < 5; i++) { - index = pathStr.lastIndexOf(Path.SEPARATOR_CHAR, index - 1); - } - if (index > 0) { - Path rootDir = getSidelineDir(); - Path dst = new Path(rootDir, pathStr.substring(index + 1)); - fs.mkdirs(dst.getParent()); - LOG.info("Trying to sildeline reference file " - + path + " to " + dst); - setShouldRerun(); + // Sidelining will happen into ${hbase.rootdir}/{$sidelinedir} directory with the same directory structure + boolean success = sidelineFile(fs, hbaseRoot, path); - success = fs.rename(path, dst); - } if (!success) { LOG.error("Failed to sideline reference file " + path); }