hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zhang...@apache.org
Subject hbase git commit: HBASE-16266 Do not throw ScannerTimeoutException when catch UnknownScannerException
Date Mon, 25 Jul 2016 14:54:29 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1 a8dd359d7 -> f35b2c45d


HBASE-16266 Do not throw ScannerTimeoutException when catch UnknownScannerException

Signed-off-by: zhangduo <zhangduo@apache.org>

Conflicts:
	hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestScannerTimeout.java


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/f35b2c45
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/f35b2c45
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/f35b2c45

Branch: refs/heads/branch-1
Commit: f35b2c45d4a87bf03d70d541fa105b82ddd3ac97
Parents: a8dd359
Author: Phil Yang <ud1937@gmail.com>
Authored: Fri Jul 22 11:58:48 2016 +0800
Committer: zhangduo <zhangduo@apache.org>
Committed: Mon Jul 25 22:37:59 2016 +0800

----------------------------------------------------------------------
 .../hadoop/hbase/client/ClientScanner.java      | 38 +++++++-------------
 .../hbase/TestPartialResultsFromClientSide.java | 20 +++++++++++
 .../hadoop/hbase/client/TestScannerTimeout.java | 33 -----------------
 3 files changed, 32 insertions(+), 59 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/f35b2c45/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ClientScanner.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ClientScanner.java
b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ClientScanner.java
index d6b5757..1a9df97 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ClientScanner.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ClientScanner.java
@@ -426,34 +426,20 @@ public class ClientScanner extends AbstractClientScanner {
         clearPartialResults();
         // DNRIOEs are thrown to make us break out of retries. Some types of DNRIOEs want
us
         // to reset the scanner and come back in again.
-        if (e instanceof UnknownScannerException) {
-          long timeout = lastNext + scannerTimeout;
-          // If we are over the timeout, throw this exception to the client wrapped in
-          // a ScannerTimeoutException. Else, it's because the region moved and we used the
old
-          // id against the new region server; reset the scanner.
-          if (timeout < System.currentTimeMillis()) {
-            LOG.info("For hints related to the following exception, please try taking a look
at: "
-                    + "https://hbase.apache.org/book.html#trouble.client.scantimeout");
-            long elapsed = System.currentTimeMillis() - lastNext;
-            ScannerTimeoutException ex =
-                new ScannerTimeoutException(elapsed + "ms passed since the last invocation,
"
-                    + "timeout is currently set to " + scannerTimeout);
-            ex.initCause(e);
-            throw ex;
-          }
+
+        // If exception is any but the list below throw it back to the client; else setup
+        // the scanner and retry.
+        Throwable cause = e.getCause();
+        if ((cause != null && cause instanceof NotServingRegionException) ||
+            (cause != null && cause instanceof RegionServerStoppedException) ||
+            e instanceof OutOfOrderScannerNextException ||
+            e instanceof UnknownScannerException ) {
+          // Pass. It is easier writing the if loop test as list of what is allowed rather
than
+          // as a list of what is not allowed... so if in here, it means we do not throw.
         } else {
-          // If exception is any but the list below throw it back to the client; else setup
-          // the scanner and retry.
-          Throwable cause = e.getCause();
-          if ((cause != null && cause instanceof NotServingRegionException) ||
-              (cause != null && cause instanceof RegionServerStoppedException) ||
-              e instanceof OutOfOrderScannerNextException) {
-            // Pass. It is easier writing the if loop test as list of what is allowed rather
than
-            // as a list of what is not allowed... so if in here, it means we do not throw.
-          } else {
-            throw e;
-          }
+          throw e;
         }
+
         // Else, its signal from depths of ScannerCallable that we need to reset the scanner.
         if (this.lastResult != null) {
           // The region has moved. We need to open a brand new scanner at the new location.

http://git-wip-us.apache.org/repos/asf/hbase/blob/f35b2c45/hbase-server/src/test/java/org/apache/hadoop/hbase/TestPartialResultsFromClientSide.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestPartialResultsFromClientSide.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestPartialResultsFromClientSide.java
index 32ca13d..60ab440 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestPartialResultsFromClientSide.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestPartialResultsFromClientSide.java
@@ -99,8 +99,11 @@ public class TestPartialResultsFromClientSide {
   // getCellHeapSize().
   private static long CELL_HEAP_SIZE = -1;
 
+  private static long timeout = 2000;
+
   @BeforeClass
   public static void setUpBeforeClass() throws Exception {
+    TEST_UTIL.getConfiguration().setLong(HConstants.HBASE_CLIENT_SCANNER_TIMEOUT_PERIOD,
timeout);
     TEST_UTIL.startMiniCluster(MINICLUSTER_SIZE);
     TEST_UTIL.getHBaseAdmin().setBalancerRunning(false, true);
     TABLE = createTestTable(TABLE_NAME, ROWS, FAMILIES, QUALIFIERS, VALUE);
@@ -1042,5 +1045,22 @@ public class TestPartialResultsFromClientSide {
     assertCell(c3, ROWS[1], FAMILIES[0], QUALIFIERS[1]);
   }
 
+  @Test
+  public void testDontThrowUnknowScannerExceptionToClient() throws Exception {
+    Table table =
+        createTestTable(TableName.valueOf("testDontThrowUnknowScannerException"), ROWS, FAMILIES,
+            QUALIFIERS, VALUE);
+    Scan scan = new Scan();
+    scan.setCaching(1);
+    ResultScanner scanner = table.getScanner(scan);
+    scanner.next();
+    Thread.sleep(timeout * 3);
+    int count = 1;
+    while (scanner.next() != null) {
+      count++;
+    }
+    assertEquals(NUM_ROWS, count);
+    scanner.close();
+  }
 
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/hbase/blob/f35b2c45/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestScannerTimeout.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestScannerTimeout.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestScannerTimeout.java
index 286bfd6..0054d09 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestScannerTimeout.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestScannerTimeout.java
@@ -94,39 +94,6 @@ public class TestScannerTimeout {
   }
 
   /**
-   * Test that we do get a ScannerTimeoutException
-   * @throws Exception
-   */
-  @Test(timeout=300000)
-  public void test2481() throws Exception {
-    LOG.info("START ************ test2481");
-    Scan scan = new Scan();
-    scan.setCaching(1);
-    Table table =
-      new HTable(new Configuration(TEST_UTIL.getConfiguration()), TABLE_NAME);
-    ResultScanner r = table.getScanner(scan);
-    int count = 0;
-    try {
-      Result res = r.next();
-      while (res != null) {
-        count++;
-        if (count == 5) {
-          // Sleep just a bit more to be sure
-          Thread.sleep(SCANNER_TIMEOUT + THREAD_WAKE_FREQUENCY + 100);
-        }
-        res = r.next();
-      }
-    } catch (ScannerTimeoutException e) {
-      LOG.info("Got the timeout " + e.getMessage(), e);
-      return;
-    }  finally {
-      table.close();
-    }
-    fail("We should be timing out");
-    LOG.info("END ************ test2481");
-  }
-
-  /**
    * Test that scanner can continue even if the region server it was reading
    * from failed. Before 2772, it reused the same scanner id.
    * @throws Exception


Mime
View raw message