From b284da7d99d4af8e2a47b237577829d899464863 Mon Sep 17 00:00:00 2001 From: Pankaj Date: Tue, 27 Aug 2019 13:44:01 +0530 Subject: [PATCH] HBASE-22928 ScanMetrics counter update may not happen in case of exception in TableRecordReaderImpl --- .../hadoop/hbase/mapreduce/TableRecordReaderImpl.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/TableRecordReaderImpl.java b/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/TableRecordReaderImpl.java index d7a2ccb1d966..4aac38e7d955 100644 --- a/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/TableRecordReaderImpl.java +++ b/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/TableRecordReaderImpl.java @@ -77,6 +77,10 @@ public class TableRecordReaderImpl { * @throws IOException When restarting fails. */ public void restart(byte[] firstRow) throws IOException { + // Update counter metrics based on current scan before reinitializing it + if (currentScan != null) { + updateCounters(); + } currentScan = new Scan(scan); currentScan.withStartRow(firstRow); currentScan.setScanMetricsEnabled(true); @@ -219,6 +223,7 @@ public boolean nextKeyValue() throws IOException, InterruptedException { } catch (IOException e) { // do not retry if the exception tells us not to do so if (e instanceof DoNotRetryIOException) { + updateCounters(); throw e; } // try to handle all other IOExceptions by restarting @@ -257,6 +262,7 @@ public boolean nextKeyValue() throws IOException, InterruptedException { updateCounters(); return false; } catch (IOException ioe) { + updateCounters(); if (logScannerActivity) { long now = System.currentTimeMillis(); LOG.info("Mapper took " + (now-timestamp)