hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r937646 - in /hadoop/hbase/branches/0.20: CHANGES.txt src/java/org/apache/hadoop/hbase/client/HTable.java src/java/org/apache/hadoop/hbase/client/ScannerCallable.java src/test/org/apache/hadoop/hbase/client/TestScannerTimeout.java
Date Sat, 24 Apr 2010 17:08:00 GMT
Author: stack
Date: Sat Apr 24 17:08:00 2010
New Revision: 937646

URL: http://svn.apache.org/viewvc?rev=937646&view=rev
Log:
HBASE-2481 Client is not getting UnknownScannerExceptions; they are being eaten

Added:
    hadoop/hbase/branches/0.20/src/test/org/apache/hadoop/hbase/client/TestScannerTimeout.java
Modified:
    hadoop/hbase/branches/0.20/CHANGES.txt
    hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/client/HTable.java
    hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/client/ScannerCallable.java

Modified: hadoop/hbase/branches/0.20/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/CHANGES.txt?rev=937646&r1=937645&r2=937646&view=diff
==============================================================================
--- hadoop/hbase/branches/0.20/CHANGES.txt (original)
+++ hadoop/hbase/branches/0.20/CHANGES.txt Sat Apr 24 17:08:00 2010
@@ -96,6 +96,8 @@ Release 0.20.4 - Unreleased
    HBASE-2474  Bug in 2248 - mixed version reads (not allowed by spec)
    HBASE-2447  LogSyncer.addToSyncQueue doesn't check if syncer is still
                running before waiting (Todd Lipcon via Stack)
+   HBASE-2481  Client is not getting UnknownScannerExceptions; they are
+               being eaten (Jean-Daniel Cryans via Stack)
 
   IMPROVEMENTS
    HBASE-2180  Bad read performance from synchronizing hfile.fddatainputstream

Modified: hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/client/HTable.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/client/HTable.java?rev=937646&r1=937645&r2=937646&view=diff
==============================================================================
--- hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/client/HTable.java (original)
+++ hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/client/HTable.java Sat Apr
24 17:08:00 2010
@@ -2022,6 +2022,16 @@ public class HTable {
               values = getConnection().getRegionServerWithRetries(callable);
             }
           } catch (DoNotRetryIOException e) {
+            long timeout = lastNext + scannerTimeout;
+            if (e instanceof UnknownScannerException &&
+                timeout < System.currentTimeMillis()) {
+              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;
+            }
             Throwable cause = e.getCause();
             if (cause == null || !(cause instanceof NotServingRegionException)) {
               throw e;
@@ -2037,14 +2047,6 @@ public class HTable {
             // Clear region
             this.currentRegion = null;
             continue;
-          } catch (IOException e) {
-            if (e instanceof UnknownScannerException &&
-                lastNext + scannerTimeout < System.currentTimeMillis()) {
-              ScannerTimeoutException ex = new ScannerTimeoutException();
-              ex.initCause(e);
-              throw ex;
-            }
-            throw e;
           }
           lastNext = System.currentTimeMillis();
           if (values != null && values.length > 0) {

Modified: hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/client/ScannerCallable.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/client/ScannerCallable.java?rev=937646&r1=937645&r2=937646&view=diff
==============================================================================
--- hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/client/ScannerCallable.java
(original)
+++ hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/client/ScannerCallable.java
Sat Apr 24 17:08:00 2010
@@ -81,11 +81,15 @@ public class ScannerCallable extends Ser
         if (e instanceof RemoteException) {
           ioe = RemoteExceptionHandler.decodeRemoteException((RemoteException)e);
         }
-        if (ioe != null && ioe instanceof NotServingRegionException) {
+        if (ioe != null) {
+          if (ioe instanceof NotServingRegionException) {
           // Throw a DNRE so that we break out of cycle of calling NSRE
           // when what we need is to open scanner against new location.
           // Attach NSRE to signal client that it needs to resetup scanner.
           throw new DoNotRetryIOException("Reset scanner", ioe);
+          } else if (ioe instanceof DoNotRetryIOException) {
+            throw ioe;
+          }
         }
       }
       return rrs;

Added: hadoop/hbase/branches/0.20/src/test/org/apache/hadoop/hbase/client/TestScannerTimeout.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/test/org/apache/hadoop/hbase/client/TestScannerTimeout.java?rev=937646&view=auto
==============================================================================
--- hadoop/hbase/branches/0.20/src/test/org/apache/hadoop/hbase/client/TestScannerTimeout.java
(added)
+++ hadoop/hbase/branches/0.20/src/test/org/apache/hadoop/hbase/client/TestScannerTimeout.java
Sat Apr 24 17:08:00 2010
@@ -0,0 +1,91 @@
+package org.apache.hadoop.hbase.client;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.hbase.HBaseTestingUtility;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+/**
+ * Test various scanner timeout issues.
+ */
+public class TestScannerTimeout {
+
+  private final static HBaseTestingUtility
+      TEST_UTIL = new HBaseTestingUtility();
+
+  final Log LOG = LogFactory.getLog(getClass());
+  private final byte[] someBytes = Bytes.toBytes("f");
+
+   /**
+   * @throws java.lang.Exception
+   */
+  @BeforeClass
+  public static void setUpBeforeClass() throws Exception {
+    HBaseConfiguration c = TEST_UTIL.getConfiguration();
+    c.setInt("hbase.regionserver.lease.period", 1000);
+    TEST_UTIL.startMiniCluster(1);
+  }
+
+  /**
+   * @throws java.lang.Exception
+   */
+  @AfterClass
+  public static void tearDownAfterClass() throws Exception {
+    TEST_UTIL.shutdownMiniCluster();
+  }
+
+  /**
+   * @throws java.lang.Exception
+   */
+  @Before
+  public void setUp() throws Exception {
+  }
+
+  /**
+   * @throws java.lang.Exception
+   */
+  @After
+  public void tearDown() throws Exception {
+  }
+
+  /**
+   * Test that we do get a ScannerTimeoutException
+   * @throws Exception
+   */
+  @Test
+  public void test2481() throws Exception {
+    int initialCount = 10;
+    HTable t = TEST_UTIL.createTable(Bytes.toBytes("t"), someBytes);
+    for (int i = 0; i < initialCount; i++) {
+      Put put = new Put(Bytes.toBytes(i));
+      put.add(someBytes, someBytes, someBytes);
+      t.put(put);
+    }
+    Scan scan = new Scan();
+    ResultScanner r = t.getScanner(scan);
+    int count = 0;
+    try {
+      Result res = r.next();
+      while (res != null) {
+        count++;
+        if (count == 5) {
+          Thread.sleep(1500);
+        }
+        res = r.next();
+      }
+    } catch (ScannerTimeoutException e) {
+      LOG.info("Got the timeout " + e.getMessage(), e);
+      return;
+    }
+    fail("We should be timing out");
+  }
+}



Mime
View raw message