From 7465c319472dfb3c98474369cdc15514eeea6293 Mon Sep 17 00:00:00 2001 From: Jeffrey Zhong Date: Mon, 2 Jun 2014 17:56:15 -0700 Subject: [PATCH] HBASE-10922: Log splitting status should always be closed --- .../hbase/regionserver/wal/HLogSplitter.java | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLogSplitter.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLogSplitter.java index 22adaf97f99..00e9f157d15 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLogSplitter.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLogSplitter.java @@ -269,10 +269,10 @@ public class HLogSplitter { int editsCount = 0; int editsSkipped = 0; + status = + TaskMonitor.get().createStatus( + "Splitting log file " + logfile.getPath() + "into a temporary staging area."); try { - status = TaskMonitor.get().createStatus( - "Splitting log file " + logfile.getPath() + - "into a temporary staging area."); long logLength = logfile.getLen(); LOG.info("Splitting hlog: " + logPath + ", length=" + logLength); LOG.info("DistributedLogReplay = " + this.distributedLogReplay); @@ -290,7 +290,6 @@ public class HLogSplitter { isCorrupted = true; } if (in == null) { - status.markComplete("Was nothing to split in log file"); LOG.warn("Nothing to split in log file " + logPath); return true; } @@ -364,14 +363,21 @@ public class HLogSplitter { throw e; } finally { LOG.debug("Finishing writing output logs and closing down."); - if (outputSinkStarted) { - progress_failed = outputSink.finishWritingAndClose() == null; + try { + if (outputSinkStarted) { + // Set progress_failed to true as the immediate following statement will reset its value + // when finishWritingAndClose() throws exception, progress_failed has the right value + progress_failed = true; + progress_failed = outputSink.finishWritingAndClose() == null; + } + } finally { + String msg = + "Processed " + editsCount + " edits across " + outputSink.getNumberOfRecoveredRegions() + + " regions; log file=" + logPath + " is corrupted = " + isCorrupted + + " progress failed = " + progress_failed; + LOG.info(msg); + status.markComplete(msg); } - String msg = "Processed " + editsCount + " edits across " - + outputSink.getNumberOfRecoveredRegions() + " regions; log file=" + logPath - + " is corrupted = " + isCorrupted + " progress failed = " + progress_failed; - LOG.info(msg); - status.markComplete(msg); } return !progress_failed; }