From f521000d7883e83943b948989f05bfe49d78f5db Mon Sep 17 00:00:00 2001 From: Guanghao Zhang Date: Thu, 23 Nov 2017 17:30:02 +0800 Subject: [PATCH] HBASE-19337 AsyncMetaTableAccessor may hang when call ScanController.terminate many times --- .../hadoop/hbase/AsyncMetaTableAccessor.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/AsyncMetaTableAccessor.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/AsyncMetaTableAccessor.java index 4c1d602e91b..d2af95508de 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/AsyncMetaTableAccessor.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/AsyncMetaTableAccessor.java @@ -303,8 +303,8 @@ public class AsyncMetaTableAccessor { startRow.ifPresent(scan::withStartRow); stopRow.ifPresent(scan::withStopRow); - if (LOG.isTraceEnabled()) { - LOG.trace("Scanning META" + " starting at row=" + Bytes.toStringBinary(scan.getStartRow()) + if (LOG.isDebugEnabled()) { + LOG.debug("Scanning META" + " starting at row=" + Bytes.toStringBinary(scan.getStartRow()) + " stopping at row=" + Bytes.toStringBinary(scan.getStopRow()) + " for max=" + rowUpperLimit + " with caching=" + scan.getCaching()); } @@ -346,19 +346,26 @@ public class AsyncMetaTableAccessor { @Override public void onNext(Result[] results, ScanController controller) { + boolean terminateScan = false; for (Result result : results) { try { if (!visitor.visit(result)) { - controller.terminate(); + terminateScan = true; + break; } - } catch (IOException e) { + } catch (Exception e) { future.completeExceptionally(e); - controller.terminate(); + terminateScan = true; + break; } if (++currentRowCount >= rowUpperLimit) { - controller.terminate(); + terminateScan = true; + break; } } + if (terminateScan) { + controller.terminate(); + } } }