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

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


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

commit 59e635a0bf2292d3037d2444d0be5955499c391a
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 9a79ad3fc24..25fcbbec881 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
@@ -60,6 +60,7 @@ import org.apache.hadoop.hbase.HConstants;
 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.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;
@@ -1115,4 +1116,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