You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zg...@apache.org on 2020/03/22 08:40:10 UTC
[hbase] branch master updated: HBASE-23633 Find a way to handle the
corrupt recovered hfiles (#1233)
This is an automated email from the ASF dual-hosted git repository.
zghao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/master by this push:
new ca533a7 HBASE-23633 Find a way to handle the corrupt recovered hfiles (#1233)
ca533a7 is described below
commit ca533a77cbfc9604e8acce06662aa4017b584b4f
Author: Pankaj <pa...@apache.org>
AuthorDate: Sun Mar 22 14:09:56 2020 +0530
HBASE-23633 Find a way to handle the corrupt recovered hfiles (#1233)
Signed-off-by: Guanghao Zhang <zg...@apache.org>
---
.../apache/hadoop/hbase/regionserver/HRegion.java | 64 +++++++++++++---------
1 file changed, 37 insertions(+), 27 deletions(-)
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
index d13cc62..11a1018 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
@@ -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;
}