HBASE-23633 Find a way to handle the corrupt recovered hfiles (#1233)
Signed-off-by: Guanghao Zhang <zghao@apache.org>
This commit is contained in:
parent
9b4e75a7f6
commit
ca533a77cb
|
@ -4795,7 +4795,9 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
|
|||
LOG.warn("Null or non-existent edits file: " + edits);
|
||||
continue;
|
||||
}
|
||||
if (isZeroLengthThenDelete(fs, edits)) continue;
|
||||
if (isZeroLengthThenDelete(fs, fs.getFileStatus(edits), edits)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
long maxSeqId;
|
||||
String fileName = edits.getName();
|
||||
|
@ -4815,29 +4817,29 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
|
|||
// if seqId is greater
|
||||
seqid = Math.max(seqid, replayRecoveredEdits(edits, maxSeqIdInStores, reporter, fs));
|
||||
} catch (IOException e) {
|
||||
boolean skipErrors = conf.getBoolean(
|
||||
HConstants.HREGION_EDITS_REPLAY_SKIP_ERRORS,
|
||||
conf.getBoolean(
|
||||
"hbase.skip.errors",
|
||||
HConstants.DEFAULT_HREGION_EDITS_REPLAY_SKIP_ERRORS));
|
||||
if (conf.get("hbase.skip.errors") != null) {
|
||||
LOG.warn(
|
||||
"The property 'hbase.skip.errors' has been deprecated. Please use " +
|
||||
HConstants.HREGION_EDITS_REPLAY_SKIP_ERRORS + " instead.");
|
||||
}
|
||||
if (skipErrors) {
|
||||
Path p = WALSplitUtil.moveAsideBadEditsFile(fs, edits);
|
||||
LOG.error(HConstants.HREGION_EDITS_REPLAY_SKIP_ERRORS
|
||||
+ "=true so continuing. Renamed " + edits +
|
||||
" as " + p, e);
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
handleException(fs, edits, e);
|
||||
}
|
||||
}
|
||||
return seqid;
|
||||
}
|
||||
|
||||
private void handleException(FileSystem fs, Path edits, IOException e) throws IOException {
|
||||
boolean skipErrors = conf.getBoolean(HConstants.HREGION_EDITS_REPLAY_SKIP_ERRORS,
|
||||
conf.getBoolean("hbase.skip.errors", HConstants.DEFAULT_HREGION_EDITS_REPLAY_SKIP_ERRORS));
|
||||
if (conf.get("hbase.skip.errors") != null) {
|
||||
LOG.warn("The property 'hbase.skip.errors' has been deprecated. Please use "
|
||||
+ HConstants.HREGION_EDITS_REPLAY_SKIP_ERRORS + " instead.");
|
||||
}
|
||||
if (skipErrors) {
|
||||
Path p = WALSplitUtil.moveAsideBadEditsFile(fs, edits);
|
||||
LOG.error(HConstants.HREGION_EDITS_REPLAY_SKIP_ERRORS + "=true so continuing. Renamed "
|
||||
+ edits + " as " + p,
|
||||
e);
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param edits File of recovered edits.
|
||||
* @param maxSeqIdInStores Maximum sequenceid found in each store. Edits in wal must be larger
|
||||
|
@ -5437,12 +5439,21 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
|
|||
WALSplitUtil.getRecoveredHFiles(fs.getFileSystem(), regionDir, familyName);
|
||||
if (files != null && files.length != 0) {
|
||||
for (FileStatus file : files) {
|
||||
store.assertBulkLoadHFileOk(file.getPath());
|
||||
Pair<Path, Path> pair = store.preBulkLoadHFile(file.getPath().toString(), -1);
|
||||
Path filePath = file.getPath();
|
||||
// If file length is zero then delete it
|
||||
if (isZeroLengthThenDelete(fs.getFileSystem(), file, filePath)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
store.assertBulkLoadHFileOk(filePath);
|
||||
} catch (IOException e) {
|
||||
handleException(fs.getFileSystem(), filePath, e);
|
||||
}
|
||||
Pair<Path, Path> pair = store.preBulkLoadHFile(filePath.toString(), -1);
|
||||
store.bulkLoadHFile(Bytes.toBytes(familyName), pair.getFirst().toString(),
|
||||
pair.getSecond());
|
||||
maxSeqId =
|
||||
Math.max(maxSeqId, WALSplitUtil.getSeqIdForRecoveredHFile(file.getPath().getName()));
|
||||
pair.getSecond());
|
||||
maxSeqId = Math.max(maxSeqId, WALSplitUtil.getSeqIdForRecoveredHFile(filePath.getName()));
|
||||
}
|
||||
if (this.rsServices != null && store.needsCompaction()) {
|
||||
this.rsServices.getCompactionRequestor()
|
||||
|
@ -5921,9 +5932,8 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
|
|||
* @return True if file was zero-length (and if so, we'll delete it in here).
|
||||
* @throws IOException
|
||||
*/
|
||||
private static boolean isZeroLengthThenDelete(final FileSystem fs, final Path p)
|
||||
throws IOException {
|
||||
FileStatus stat = fs.getFileStatus(p);
|
||||
private static boolean isZeroLengthThenDelete(final FileSystem fs, final FileStatus stat,
|
||||
final Path p) throws IOException {
|
||||
if (stat.getLen() > 0) {
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue