You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ra...@apache.org on 2017/12/14 13:42:36 UTC

hbase git commit: HBASE-19511 Splits causes blocks to be cached again and so such blocks cannot be evicted from bucket cache (Ram) Signed-off Duo Zhang, Anoop Sam John

Repository: hbase
Updated Branches:
  refs/heads/master fe316fe7a -> d5aefbd2c


HBASE-19511 Splits causes blocks to be cached again and so such blocks cannot be evicted from bucket cache (Ram)
Signed-off Duo Zhang, Anoop Sam John <palomino219@gmail.com, anoop.hbase@gmail.com>


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

Branch: refs/heads/master
Commit: d5aefbd2c78463bf4b3815f38f43dd745035cc93
Parents: fe316fe
Author: ramkrish86 <ra...@gmail.com>
Authored: Fri Dec 15 00:35:20 2017 +0530
Committer: ramkrish86 <ra...@gmail.com>
Committed: Fri Dec 15 00:35:20 2017 +0530

----------------------------------------------------------------------
 .../hadoop/hbase/io/hfile/bucket/BucketCache.java  | 17 +++++++++++------
 .../hbase/client/TestBlockEvictionFromClient.java  | 16 ++++++++++------
 2 files changed, 21 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/d5aefbd2/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java
index ac842f6..0ced7c1 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java
@@ -427,13 +427,18 @@ public class BucketCache implements BlockCache, HeapSize {
 
     if (backingMap.containsKey(cacheKey)) {
       Cacheable existingBlock = getBlock(cacheKey, false, false, false);
-      if (BlockCacheUtil.compareCacheBlock(cachedItem, existingBlock) != 0) {
-        throw new RuntimeException("Cached block contents differ, which should not have happened."
-            + "cacheKey:" + cacheKey);
+      try {
+        if (BlockCacheUtil.compareCacheBlock(cachedItem, existingBlock) != 0) {
+          throw new RuntimeException("Cached block contents differ, which should not have happened."
+              + "cacheKey:" + cacheKey);
+        }
+        String msg = "Caching an already cached block: " + cacheKey;
+        msg += ". This is harmless and can happen in rare cases (see HBASE-8547)";
+        LOG.warn(msg);
+      } finally {
+        // return the block since we need to decrement the count
+        returnBlock(cacheKey, existingBlock);
       }
-       String msg = "Caching an already cached block: " + cacheKey;
-       msg += ". This is harmless and can happen in rare cases (see HBASE-8547)";
-       LOG.warn(msg);
       return;
     }
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/d5aefbd2/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestBlockEvictionFromClient.java
----------------------------------------------------------------------
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 d6f9d71..9388144 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
@@ -23,6 +23,7 @@ import static org.junit.Assert.assertTrue;
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Optional;
@@ -39,6 +40,7 @@ import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.Cell;
 import org.apache.hadoop.hbase.HBaseTestingUtility;
 import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.coprocessor.CoprocessorHost;
 import org.apache.hadoop.hbase.coprocessor.MultiRowMutationEndpoint;
@@ -64,7 +66,6 @@ import org.junit.After;
 import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.BeforeClass;
-import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
@@ -201,7 +202,6 @@ public class TestBlockEvictionFromClient {
       assertTrue(Bytes.equals(table.get(new Get(ROW)).value(), data));
       // data was in memstore so don't expect any changes
       // flush the data
-      System.out.println("Flushing cache in problematic area");
       // Should create one Hfile with 2 blocks
       region.flush(true);
       // Load cache
@@ -597,10 +597,14 @@ public class TestBlockEvictionFromClient {
       region.flush(true);
       LOG.info("About to SPLIT on " + Bytes.toString(ROW1));
       TEST_UTIL.getAdmin().split(tableName, ROW1);
-      List<RegionInfo> tableRegions = TEST_UTIL.getAdmin().getRegions(tableName);
       // Wait for splits
-      while (tableRegions.size() != 2) {
-        tableRegions = TEST_UTIL.getAdmin().getRegions(tableName);
+      Collection<ServerName> regionServers = TEST_UTIL.getAdmin().getRegionServers();
+      Iterator<ServerName> serverItr = regionServers.iterator();
+      serverItr.hasNext();
+      ServerName rs = serverItr.next();
+      List<RegionInfo> onlineRegions = TEST_UTIL.getAdmin().getRegions(rs);
+      while (onlineRegions.size() != 2) {
+        onlineRegions = TEST_UTIL.getAdmin().getRegions(rs);
         Thread.sleep(100);
         LOG.info("Waiting on SPLIT to complete...");
       }
@@ -862,7 +866,7 @@ public class TestBlockEvictionFromClient {
     testScanWithCompactionInternals(name.getMethodName(), false);
   }
 
-  @Ignore @Test
+  @Test
   public void testReverseScanWithCompaction() throws IOException, InterruptedException {
     testScanWithCompactionInternals(name.getMethodName(), true);
   }