This is an automated email from the ASF dual-hosted git repository. shahrs87 pushed a commit to branch branch-2.5 in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2.5 by this push: new 6c46d7290c6 HBASE-28204 Canary can take lot more time If region starts with delete markers (#5522) 6c46d7290c6 is described below commit 6c46d7290c605530a9b22adcd654955cfca62dde Author: Monani Mihir <monani.mi...@gmail.com> AuthorDate: Wed Nov 15 13:34:05 2023 -0800 HBASE-28204 Canary can take lot more time If region starts with delete markers (#5522) Co-authored-by: Mihir Monani <mihir6...@apache.org> (cherry picked from commit ce9eabe61661599d0b424026841eaf0087d84805) --- .../org/apache/hadoop/hbase/tool/CanaryTool.java | 44 +++++++++++----------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/CanaryTool.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/CanaryTool.java index 95c92536567..e4c47c6bdd8 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/CanaryTool.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/CanaryTool.java @@ -510,38 +510,38 @@ public class CanaryTool implements Tool, Canary { private Void readColumnFamily(Table table, ColumnFamilyDescriptor column) { byte[] startKey = null; - Get get = null; - Scan scan = null; + Scan scan = new Scan(); ResultScanner rs = null; StopWatch stopWatch = new StopWatch(); startKey = region.getStartKey(); // Can't do a get on empty start row so do a Scan of first element if any instead. if (startKey.length > 0) { - get = new Get(startKey); - get.setCacheBlocks(false); - get.setFilter(new FirstKeyOnlyFilter()); - get.addFamily(column.getName()); - } else { - scan = new Scan(); - LOG.debug("rawScan {} for {}", rawScanEnabled, region.getTable()); - scan.setRaw(rawScanEnabled); - scan.setCaching(1); - scan.setCacheBlocks(false); - scan.setFilter(new FirstKeyOnlyFilter()); - scan.addFamily(column.getName()); - scan.setMaxResultSize(1L); - scan.setOneRowLimit(); + // There are 4 types of region for any table. + // 1. Start and End key are empty. (Table with Single region) + // 2. Start key is empty. (First region of the table) + // 3. End key is empty. (Last region of the table) + // 4. Region with Start & End key. (All the regions between first & last region of the + // table.) + // + // Since Scan only takes Start and/or End Row and doesn't accept the region ID, + // we set the start row when Regions are of type 3 OR 4 as mentioned above. + // For type 1 and 2, We don't need to set this option. + scan.withStartRow(startKey); } + LOG.debug("rawScan {} for {}", rawScanEnabled, region.getTable()); + scan.setRaw(rawScanEnabled); + scan.setCaching(1); + scan.setCacheBlocks(false); + scan.setFilter(new FirstKeyOnlyFilter()); + scan.addFamily(column.getName()); + scan.setMaxResultSize(1L); + scan.setOneRowLimit(); LOG.debug("Reading from {} {} {} {}", region.getTable(), region.getRegionNameAsString(), column.getNameAsString(), Bytes.toStringBinary(startKey)); try { stopWatch.start(); - if (startKey.length > 0) { - table.get(get); - } else { - rs = table.getScanner(scan); - rs.next(); - } + rs = table.getScanner(scan); + rs.next(); stopWatch.stop(); this.readWriteLatency.add(stopWatch.getTime()); sink.publishReadTiming(serverName, region, column, stopWatch.getTime());