This is an automated email from the ASF dual-hosted git repository.

wchevreuil pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-2 by this push:
     new d55b2416a79 HBASE-29493 Triage TestBucketCacheRefCnt.testInBucketCache 
intermittent failure caused by RAMCache draining in between (#7205) (#7206)
d55b2416a79 is described below

commit d55b2416a79eba8d198c991dbb19512673bb6c4d
Author: Wellington Ramos Chevreuil <[email protected]>
AuthorDate: Tue Aug 26 09:49:07 2025 +0100

    HBASE-29493 Triage TestBucketCacheRefCnt.testInBucketCache intermittent 
failure caused by RAMCache draining in between (#7205) (#7206)
    
    Signed-off-by: Wellington Chevreuil <[email protected]>
    Co-authored-by: Umesh <[email protected]>
---
 .../hadoop/hbase/io/hfile/bucket/TestBucketCacheRefCnt.java      | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestBucketCacheRefCnt.java
 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestBucketCacheRefCnt.java
index e71817e6a3f..4ee3f37819f 100644
--- 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestBucketCacheRefCnt.java
+++ 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestBucketCacheRefCnt.java
@@ -32,6 +32,7 @@ import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicReference;
 import org.apache.hadoop.hbase.HBaseClassTestRule;
 import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.hbase.Waiter;
 import org.apache.hadoop.hbase.io.ByteBuffAllocator;
 import org.apache.hadoop.hbase.io.hfile.BlockCacheKey;
 import org.apache.hadoop.hbase.io.hfile.BlockCacheUtil;
@@ -229,6 +230,10 @@ public class TestBucketCacheRefCnt {
       cache.cacheBlock(key, blk);
       assertTrue(blk.refCnt() == 1 || blk.refCnt() == 2);
 
+      // wait for block to move to backing map because refCnt get refreshed 
once block moves to
+      // backing map
+      Waiter.waitFor(HBaseConfiguration.create(), 12000, () -> 
isRamCacheDrained(key, cache));
+
       Cacheable block1 = cache.getBlock(key, false, false, false);
       assertTrue(block1.refCnt() >= 2);
       assertTrue(((HFileBlock) block1).getByteBuffAllocator() == alloc);
@@ -262,6 +267,10 @@ public class TestBucketCacheRefCnt {
     }
   }
 
+  private boolean isRamCacheDrained(BlockCacheKey key, BucketCache cache) {
+    return cache.backingMap.containsKey(key) && 
!cache.ramCache.containsKey(key);
+  }
+
   @Test
   public void testMarkStaleAsEvicted() throws Exception {
     cache = create(1, 1000);

Reply via email to