Skip to content

Commit f5aafe8

Browse files
Huginn-kiowchevreuil
authored andcommitted
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]>
1 parent 4ac5b6d commit f5aafe8

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketEntry.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public class BucketEntry implements HBaseReferenceCounted {
117117
this.onDiskSizeWithHeader = onDiskSizeWithHeader;
118118
this.accessCounter = accessCounter;
119119
this.cachedTime = cachedTime;
120-
this.priority = inMemory ? BlockPriority.MEMORY : BlockPriority.MULTI;
120+
this.priority = inMemory ? BlockPriority.MEMORY : BlockPriority.SINGLE;
121121
this.refCnt = RefCnt.create(createRecycler.apply(this));
122122
this.markedAsEvicted = new AtomicBoolean(false);
123123
this.allocator = allocator;

hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/bucket/TestBucketCache.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
import org.apache.hadoop.hbase.Waiter;
6161
import org.apache.hadoop.hbase.io.ByteBuffAllocator;
6262
import org.apache.hadoop.hbase.io.hfile.BlockCacheKey;
63+
import org.apache.hadoop.hbase.io.hfile.BlockPriority;
6364
import org.apache.hadoop.hbase.io.hfile.BlockType;
6465
import org.apache.hadoop.hbase.io.hfile.CacheTestUtils;
6566
import org.apache.hadoop.hbase.io.hfile.CacheTestUtils.HFileBlockPair;
@@ -1115,4 +1116,13 @@ private BucketCache testEvictOrphans(long orphanEvictionGracePeriod) throws Exce
11151116
bucketCache.freeSpace("test");
11161117
return bucketCache;
11171118
}
1119+
1120+
@Test
1121+
public void testBlockPriority() throws Exception {
1122+
HFileBlockPair block = CacheTestUtils.generateHFileBlocks(BLOCK_SIZE, 1)[0];
1123+
cacheAndWaitUntilFlushedToBucket(cache, block.getBlockName(), block.getBlock(), true);
1124+
assertEquals(cache.backingMap.get(block.getBlockName()).getPriority(), BlockPriority.SINGLE);
1125+
cache.getBlock(block.getBlockName(), true, false, true);
1126+
assertEquals(cache.backingMap.get(block.getBlockName()).getPriority(), BlockPriority.MULTI);
1127+
}
11181128
}

0 commit comments

Comments
 (0)