You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by "huginn (Jira)" <ji...@apache.org> on 2025/10/17 04:10:00 UTC
[jira] [Comment Edited] (HBASE-29667) The block priority is initialized as MULTI when the data block is first written into the BucketCache
[ https://issues.apache.org/jira/browse/HBASE-29667?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18030532#comment-18030532 ]
huginn edited comment on HBASE-29667 at 10/17/25 4:09 AM:
----------------------------------------------------------
[~zhangduo] Can you please help me take a look at this issue?
was (Author: JIRAUSER309834):
[~zhangduo] Can you help me take a look at this issue?
> The block priority is initialized as MULTI when the data block is first written into the BucketCache
> ----------------------------------------------------------------------------------------------------
>
> Key: HBASE-29667
> URL: https://issues.apache.org/jira/browse/HBASE-29667
> Project: HBase
> Issue Type: Bug
> Components: BucketCache
> Reporter: huginn
> Priority: Major
>
> When a data block is first written into the BucketCahce, BucketCache allocates a bucket for it, generates and returns the corresponding BucketEntry, which will later be placed into the BackingMap. I notice that BucketEntry sets the Block Priority to MULTI during initialization. Is this a bug that causes the BucketCache to only contain blocks with priorities MULTI and MEM, thereby confusing single-access and multiple-access blocks? In fact, the BucketCache has logic to upgrade SINGLE to MULTI when the block is accessed again, as well as different cleanup logic for blocks with different block priorities.
> {code:java}
> public BucketEntry writeToCache(final IOEngine ioEngine, final BucketAllocator alloc,
> final LongAdder realCacheSize, Function<BucketEntry, Recycler> createRecycler,
> ByteBuffer metaBuff, final Long acceptableSize) throws IOException {
> int len = data.getSerializedLength();
> if (len == 0) {
> return null;
> }
> if (isCachePersistent && data instanceof HFileBlock) {
> len += Long.BYTES;
> }
> long offset = alloc.allocateBlock(len);
> if (isPrefetch() && alloc.getUsedSize() > acceptableSize) {
> alloc.freeBlock(offset, len);
> return null;
> }
> boolean succ = false;
> BucketEntry bucketEntry = null;
> try {
> int diskSizeWithHeader = (data instanceof HFileBlock)
> ? ((HFileBlock) data).getOnDiskSizeWithHeader()
> : data.getSerializedLength();
> bucketEntry = new BucketEntry(offset, len, diskSizeWithHeader, accessCounter, inMemory,
> createRecycler, getByteBuffAllocator());
> bucketEntry.setDeserializerReference(data.getDeserializer());
> ...
> }
> {code}
> {code:java}
> BucketEntry(long offset, int length, int onDiskSizeWithHeader, long accessCounter,
> long cachedTime, boolean inMemory, Function<BucketEntry, Recycler> createRecycler,
> ByteBuffAllocator allocator) {
> if (createRecycler == null) {
> throw new IllegalArgumentException("createRecycler could not be null!");
> }
> setOffset(offset);
> this.length = length;
> this.onDiskSizeWithHeader = onDiskSizeWithHeader;
> this.accessCounter = accessCounter;
> this.cachedTime = cachedTime;
> this.priority = inMemory ? BlockPriority.MEMORY : BlockPriority.MULTI;
> this.refCnt = RefCnt.create(createRecycler.apply(this));
> this.markedAsEvicted = new AtomicBoolean(false);
> this.allocator = allocator;
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)