HBASE-19337 AsyncMetaTableAccessor may hang when call ScanController.terminate many times

This commit is contained in:
Guanghao Zhang 2017-11-23 17:30:02 +08:00
parent 6ac6ae3fa2
commit 0406d06533
1 changed files with 13 additions and 6 deletions

View File

@ -303,8 +303,8 @@ public class AsyncMetaTableAccessor {
startRow.ifPresent(scan::withStartRow); startRow.ifPresent(scan::withStartRow);
stopRow.ifPresent(scan::withStopRow); stopRow.ifPresent(scan::withStopRow);
if (LOG.isTraceEnabled()) { if (LOG.isDebugEnabled()) {
LOG.trace("Scanning META" + " starting at row=" + Bytes.toStringBinary(scan.getStartRow()) LOG.debug("Scanning META" + " starting at row=" + Bytes.toStringBinary(scan.getStartRow())
+ " stopping at row=" + Bytes.toStringBinary(scan.getStopRow()) + " for max=" + " stopping at row=" + Bytes.toStringBinary(scan.getStopRow()) + " for max="
+ rowUpperLimit + " with caching=" + scan.getCaching()); + rowUpperLimit + " with caching=" + scan.getCaching());
} }
@ -346,19 +346,26 @@ public class AsyncMetaTableAccessor {
@Override @Override
public void onNext(Result[] results, ScanController controller) { public void onNext(Result[] results, ScanController controller) {
boolean terminateScan = false;
for (Result result : results) { for (Result result : results) {
try { try {
if (!visitor.visit(result)) { if (!visitor.visit(result)) {
controller.terminate(); terminateScan = true;
break;
} }
} catch (IOException e) { } catch (Exception e) {
future.completeExceptionally(e); future.completeExceptionally(e);
controller.terminate(); terminateScan = true;
break;
} }
if (++currentRowCount >= rowUpperLimit) { if (++currentRowCount >= rowUpperLimit) {
controller.terminate(); terminateScan = true;
break;
} }
} }
if (terminateScan) {
controller.terminate();
}
} }
} }