.../hadoop/hbase/regionserver/RSRpcServices.java | 18 +++++------------- .../hbase/client/TestBlockEvictionFromClient.java | 21 ++++----------------- 2 files changed, 9 insertions(+), 30 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java index 541680c..f2febae 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java @@ -2902,6 +2902,9 @@ public class RSRpcServices implements HBaseRPCErrorHandler, RegionReplicaUtil.isDefaultReplica(region.getRegionInfo()), isClientCellBlockSupport(context)); } + if (context != null) { + context.setCallBack(rsh.shippedCallback); + } } catch (IOException e) { // The scanner state might be left in a dirty state, so we will tell the Client to // fail this RPC and close the scanner while opening up another one from the start of @@ -2911,7 +2914,8 @@ public class RSRpcServices implements HBaseRPCErrorHandler, // We closed the scanner already. Instead of throwing the IOException, and client // retrying with the same scannerId only to get USE on the next RPC, we directly throw // a special exception to save an RPC. - if (VersionInfoUtil.hasMinimumVersion(context.getClientVersionInfo(), 1, 4)) { + if (context != null + && VersionInfoUtil.hasMinimumVersion(context.getClientVersionInfo(), 1, 4)) { // 1.4.0+ clients know how to handle throw new ScannerResetException("Scanner is closed on the server-side", e); } else { @@ -2919,18 +2923,6 @@ public class RSRpcServices implements HBaseRPCErrorHandler, throw new UnknownScannerException("Throwing UnknownScannerException to reset the client" + " scanner state for clients older than 1.3.", e); } - } finally { - if (context != null) { - context.setCallBack(rsh.shippedCallback); - } - // Adding resets expiration time on lease. - if (scanners.containsKey(scannerName)) { - ttl = this.scannerLeaseTimeoutPeriod; - // When context != null, adding back the lease will be done in callback set above. - if (context == null) { - if (lease != null) regionServer.leases.addLease(lease); - } - } } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestBlockEvictionFromClient.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestBlockEvictionFromClient.java index ba75d6e..3b19bcc 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestBlockEvictionFromClient.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestBlockEvictionFromClient.java @@ -18,6 +18,7 @@ package org.apache.hadoop.hbase.client; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import java.io.IOException; @@ -1185,23 +1186,9 @@ public class TestBlockEvictionFromClient { usedBlocksFound = true; } } - assertTrue(usedBlocksFound); - // Sleep till the scan lease would expire? Can we reduce this value? - Thread.sleep(5100); - iterator = cache.iterator(); - refCount = 0; - while (iterator.hasNext()) { - CachedBlock next = iterator.next(); - BlockCacheKey cacheKey = new BlockCacheKey(next.getFilename(), next.getOffset()); - if (cache instanceof BucketCache) { - refCount = ((BucketCache) cache).getRefCount(cacheKey); - } else if (cache instanceof CombinedBlockCache) { - refCount = ((CombinedBlockCache) cache).getRefCount(cacheKey); - } else { - continue; - } - assertEquals(0, refCount); - } + assertFalse(usedBlocksFound); + // you should always see 0 ref count. since after HBASE-16604 we always recreate the scanner + assertEquals(0, refCount); } finally { if (table != null) { table.close();