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

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


The following commit(s) were added to refs/heads/branch-2.6 by this push:
     new 6ddb8e0aae4 HBASE-29667 Correct block priority to SINGLE on the first 
write to the bucket cache (#7399)
6ddb8e0aae4 is described below

commit 6ddb8e0aae4add032e9c14903bc27aaf95b7448c
Author: Huginn <[email protected]>
AuthorDate: Tue Nov 4 17:57:25 2025 +0800

    HBASE-29667 Correct block priority to SINGLE on the first write to the 
bucket cache (#7399)
    
    Reviewed by: Kota-SH <[email protected]>
    Signed-off-by: Wellington Chevreuil <[email protected]>
---
 .../org/apache/hadoop/hbase/io/hfile/bucket/BucketEntry.java   |  2 +-
 .../apache/hadoop/hbase/io/hfile/bucket/TestBucketCache.java   | 10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketEntry.java
 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketEntry.java
index c93dac8a572..6ee95371734 100644
--- 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketEntry.java
+++ 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketEntry.java
@@ -117,7 +117,7 @@ public class BucketEntry implements HBaseReferenceCounted {
     this.onDiskSizeWithHeader = onDiskSizeWithHeader;
     this.accessCounter = accessCounter;
     this.cachedTime = cachedTime;
-    this.priority = inMemory ? BlockPriority.MEMORY : BlockPriority.MULTI;
+    this.priority = inMemory ? BlockPriority.MEMORY : BlockPriority.SINGLE;
     this.refCnt = RefCnt.create(createRecycler.apply(this));
     this.markedAsEvicted = new AtomicBoolean(false);
     this.allocator = allocator;
diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestBucketCache.java
 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestBucketCache.java
index 84731d03fa9..879a32a5036 100644
--- 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestBucketCache.java
+++ 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestBucketCache.java
@@ -59,6 +59,7 @@ import org.apache.hadoop.hbase.HBaseTestingUtility;
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.io.ByteBuffAllocator;
 import org.apache.hadoop.hbase.io.hfile.BlockCacheKey;
+import org.apache.hadoop.hbase.io.hfile.BlockPriority;
 import org.apache.hadoop.hbase.io.hfile.BlockType;
 import org.apache.hadoop.hbase.io.hfile.CacheTestUtils;
 import org.apache.hadoop.hbase.io.hfile.CacheTestUtils.HFileBlockPair;
@@ -1098,4 +1099,13 @@ public class TestBucketCache {
     bucketCache.freeSpace("test");
     return bucketCache;
   }
+
+  @Test
+  public void testBlockPriority() throws Exception {
+    HFileBlockPair block = CacheTestUtils.generateHFileBlocks(BLOCK_SIZE, 
1)[0];
+    cacheAndWaitUntilFlushedToBucket(cache, block.getBlockName(), 
block.getBlock(), true);
+    assertEquals(cache.backingMap.get(block.getBlockName()).getPriority(), 
BlockPriority.SINGLE);
+    cache.getBlock(block.getBlockName(), true, false, true);
+    assertEquals(cache.backingMap.get(block.getBlockName()).getPriority(), 
BlockPriority.MULTI);
+  }
 }

Reply via email to