From f76d6bcbf16e84c41518fe72501149d929320aea Mon Sep 17 00:00:00 2001 From: niuyulin Date: Thu, 5 Nov 2020 00:21:31 +0800 Subject: [PATCH] HBASE-25053 WAL replay should ignore 0-length files (#2437) Signed-off-by: Duo Zhang Signed-off-by: Viraj Jasani --- .../java/org/apache/hadoop/hbase/regionserver/HRegion.java | 7 +++++++ 1 file changed, 7 insertions(+) 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 3a474cd86e24..0df635295eae 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 @@ -4771,6 +4771,11 @@ long replayRecoveredEditsIfAny(Map maxSeqIdInStores, recoveredEditsDir); if (files != null) { for (FileStatus file : files) { + // it is safe to trust the zero-length in this case because we've been through rename and + // lease recovery in the above. + if (isZeroLengthThenDelete(fs, file, file.getPath())) { + continue; + } seqId = Math.max(seqId, replayRecoveredEdits(file.getPath(), maxSeqIdInStores, reporter, fs)); } @@ -5935,6 +5940,8 @@ protected void restoreEdit(HStore s, Cell cell, MemStoreSizing memstoreAccountin } /** + * make sure have been through lease recovery before get file status, so the file length can be + * trusted. * @param p File to check. * @return True if file was zero-length (and if so, we'll delete it in here). * @throws IOException