Index: hbase-server/src/main/java/org/apache/hadoop/hbase/client/ClientScanner.java =================================================================== --- hbase-server/src/main/java/org/apache/hadoop/hbase/client/ClientScanner.java (revision 1403637) +++ hbase-server/src/main/java/org/apache/hadoop/hbase/client/ClientScanner.java (working copy) @@ -63,6 +63,7 @@ private final HConnection connection; private final byte[] tableName; private final int scannerTimeout; + private final int numRetries; /** * Create a new ClientScanner for the specified table. An HConnection will be @@ -109,6 +110,8 @@ } this.scannerTimeout = conf.getInt(HConstants.HBASE_CLIENT_SCANNER_TIMEOUT_PERIOD, HConstants.DEFAULT_HBASE_CLIENT_SCANNER_TIMEOUT_PERIOD); + this.numRetries = conf.getInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, + HConstants.DEFAULT_HBASE_CLIENT_RETRIES_NUMBER); // check if application wants to collect scan metrics byte[] enableMetrics = scan.getAttribute( @@ -266,6 +269,7 @@ // This flag is set when we want to skip the result returned. We do // this when we reset scanner because it split under us. boolean skipFirst = false; + int tries = 1; do { try { if (skipFirst) { @@ -280,6 +284,7 @@ // returns an empty array if scanning is to go on and we've just // exhausted current region. values = callable.withRetries(); + tries = 1; } catch (DoNotRetryIOException e) { if (e instanceof UnknownScannerException) { long timeout = lastNext + scannerTimeout; @@ -310,6 +315,10 @@ // invocation. skipFirst = true; } + if (tries >= numRetries) { + throw new DoNotRetryIOException("Failed after attempts=" + tries, e); + } + tries++; // Clear region this.currentRegion = null; callable = null;