From 25bcc91dab89db60c1171d083909c5ceabe0f0a0 Mon Sep 17 00:00:00 2001 From: Guanghao Zhang Date: Wed, 18 Sep 2019 21:44:05 +0800 Subject: [PATCH] HBASE-23037 Make the split WAL related log more readable (#632) Signed-off-by: Duo Zhang --- .../hadoop/hbase/master/SplitLogManager.java | 11 ++++++---- .../BoundedLogWriterCreationOutputSink.java | 5 ++--- .../apache/hadoop/hbase/wal/WALSplitter.java | 21 +++++++++++++------ 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/SplitLogManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/SplitLogManager.java index 4d977d342754..e99bc167d3d4 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/SplitLogManager.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/SplitLogManager.java @@ -51,6 +51,7 @@ import org.apache.hadoop.hbase.log.HBaseMarkers; import org.apache.hadoop.hbase.monitoring.MonitoredTask; import org.apache.hadoop.hbase.monitoring.TaskMonitor; +import org.apache.hadoop.hbase.procedure2.util.StringUtils; import org.apache.hadoop.hbase.util.EnvironmentEdgeManager; import org.apache.hadoop.hbase.util.FSUtils; import org.apache.hadoop.hbase.util.HasThread; @@ -289,10 +290,12 @@ public long splitLogDistributed(final Set serverNames, final List completionService, List buffer : entryBuffers.buffers .entrySet()) { LOG.info("Submitting writeThenClose of {}", - Arrays.toString(buffer.getValue().encodedRegionName)); + Bytes.toString(buffer.getValue().encodedRegionName)); completionService.submit(new Callable() { @Override public Void call() throws Exception { @@ -148,4 +147,4 @@ private Path writeThenClose(WALSplitter.RegionEntryBuffer buffer) throws IOExcep } return dst; } -} \ No newline at end of file +} diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/WALSplitter.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/WALSplitter.java index 08166d2e0341..5d07061ed8d8 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/WALSplitter.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/WALSplitter.java @@ -44,11 +44,13 @@ import org.apache.hadoop.hbase.master.SplitLogManager; import org.apache.hadoop.hbase.monitoring.MonitoredTask; import org.apache.hadoop.hbase.monitoring.TaskMonitor; +import org.apache.hadoop.hbase.procedure2.util.StringUtils; import org.apache.hadoop.hbase.regionserver.LastSequenceId; import org.apache.hadoop.hbase.regionserver.wal.WALCellCodec; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.CancelableProgressable; import org.apache.hadoop.hbase.util.ClassSize; +import org.apache.hadoop.hbase.util.EnvironmentEdgeManager; import org.apache.hadoop.hbase.util.FSUtils; import org.apache.hadoop.hbase.wal.WAL.Entry; import org.apache.hadoop.hbase.wal.WAL.Reader; @@ -221,9 +223,11 @@ boolean splitLogFile(FileStatus logfile, CancelableProgressable reporter) throws "Splitting log file " + logfile.getPath() + "into a temporary staging area."); Reader logFileReader = null; this.fileBeingSplit = logfile; + long startTS = EnvironmentEdgeManager.currentTime(); try { long logLength = logfile.getLen(); - LOG.info("Splitting WAL={}, length={}", logPath, logLength); + LOG.info("Splitting WAL={}, size={} ({} bytes)", logPath, StringUtils.humanSize(logLength), + logLength); status.setStatus("Opening log file"); if (reporter != null && !reporter.progress()) { progress_failed = true; @@ -234,6 +238,8 @@ boolean splitLogFile(FileStatus logfile, CancelableProgressable reporter) throws LOG.warn("Nothing to split in WAL={}", logPath); return true; } + long openCost = EnvironmentEdgeManager.currentTime() - startTS; + LOG.info("Open WAL={} cost {} ms", logPath, openCost); int numOpenedFilesBeforeReporting = conf.getInt("hbase.splitlog.report.openedfiles", 3); int numOpenedFilesLastCheck = 0; outputSink.setReporter(reporter); @@ -241,6 +247,7 @@ boolean splitLogFile(FileStatus logfile, CancelableProgressable reporter) throws outputSinkStarted = true; Entry entry; Long lastFlushedSequenceId = -1L; + startTS = EnvironmentEdgeManager.currentTime(); while ((entry = getNextLogLine(logFileReader, logPath, skipErrors)) != null) { byte[] region = entry.getKey().getEncodedRegionName(); String encodedRegionNameAsStr = Bytes.toString(region); @@ -324,11 +331,13 @@ boolean splitLogFile(FileStatus logfile, CancelableProgressable reporter) throws progress_failed = outputSink.finishWritingAndClose() == null; } } finally { - String msg = - "Processed " + editsCount + " edits across " + outputSink.getNumberOfRecoveredRegions() - + " regions; edits skipped=" + editsSkipped + "; log file=" + logPath + - ", length=" + logfile.getLen() + // See if length got updated post lease recovery - ", corrupted=" + isCorrupted + ", progress failed=" + progress_failed; + long processCost = EnvironmentEdgeManager.currentTime() - startTS; + // See if length got updated post lease recovery + String msg = "Processed " + editsCount + " edits across " + + outputSink.getNumberOfRecoveredRegions() + " regions cost " + processCost + + " ms; edits skipped=" + editsSkipped + "; WAL=" + logPath + ", size=" + + StringUtils.humanSize(logfile.getLen()) + ", length=" + logfile.getLen() + + ", corrupted=" + isCorrupted + ", progress failed=" + progress_failed; LOG.info(msg); status.markComplete(msg); }