From 238c9b40bf73f6038d60ebf7c99444b7fee373ab Mon Sep 17 00:00:00 2001 From: Xiaolin Ha Date: Thu, 12 Aug 2021 17:09:18 +0800 Subject: [PATCH] HBASE-26155 JVM crash when scan (#3553) Signed-off-by: Michael Stack Signed-off-by: Duo Zhang --- .../org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java | 5 +++++ .../org/apache/hadoop/hbase/regionserver/StoreScanner.java | 3 +-- 2 files changed, 6 insertions(+), 2 deletions(-) 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 0187f5eb435..9dc40d02ccf 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 @@ -430,6 +430,11 @@ public class BucketCache implements BlockCache, HeapSize { if (cacheEnabled) { if (backingMap.containsKey(cacheKey) || ramCache.containsKey(cacheKey)) { if (BlockCacheUtil.shouldReplaceExistingCacheBlock(this, cacheKey, cachedItem)) { + BucketEntry bucketEntry = backingMap.get(cacheKey); + if (bucketEntry != null && bucketEntry.isRpcRef()) { + // avoid replace when there are RPC refs for the bucket entry in bucket cache + return; + } cacheBlockWithWaitInternal(cacheKey, cachedItem, inMemory, wait); } } else { diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java index 5ad29bb488c..9505fb07e0d 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java @@ -29,10 +29,9 @@ import org.apache.hadoop.hbase.Cell; import org.apache.hadoop.hbase.CellComparator; import org.apache.hadoop.hbase.CellUtil; import org.apache.hadoop.hbase.DoNotRetryIOException; -import org.apache.hadoop.hbase.HConstants; -import org.apache.hadoop.hbase.PrivateCellUtil; import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.KeyValueUtil; +import org.apache.hadoop.hbase.PrivateCellUtil; import org.apache.hadoop.hbase.PrivateConstants; import org.apache.hadoop.hbase.client.IsolationLevel; import org.apache.hadoop.hbase.client.Scan;