Julian Chandra Sutadi created HBASE-30454:
---------------------------------------------

             Summary: BucketCache persistence recovery downgrades MULTI blocks 
to SINGLE
                 Key: HBASE-30454
                 URL: https://issues.apache.org/jira/browse/HBASE-30454
             Project: HBase
          Issue Type: Bug
            Reporter: Julian Chandra Sutadi


HBASE-29667 reported that blocks written into the BucketCache were initialized 
with MULTI priority instead of SINGLE, so the SINGLE to MULTI promotion on 
re-access never took effect. The issue was fixed by initializing non-memory 
blocks as SINGLE in the BucketEntry constructor.

However, when the cache is restored from its persistence file 
(BucketProtoUtils.fromPB), the BucketEntry is rebuilt from its boolean inMemory 
instead of the saved priority. The constructor sets MEMORY if inMemory is true 
and SINGLE otherwise, so a persisted MULTI block comes back as SINGLE. After a 
restart, frequently accessed blocks silently lose their MULTI status and are 
more likely to be evicted until they are read again.
 
{code:java}
// BucketProtoUtils.toPB(BucketEntry): saves all three priorities
.setPriority(toPB(entry.getPriority()))

// BucketProtoUtils.fromPB: reduces the priority to a boolean
new BucketEntry(..., protoValue.getCachedTime(),
  protoValue.getPriority() == BucketCacheProtos.BlockPriority.memory,   // 
inMemory
  createRecycler, ByteBuffAllocator.HEAP);

// BucketEntry constructor (fixed by HBASE-29667)
this.priority = inMemory ? BlockPriority.MEMORY : BlockPriority.SINGLE;
{code}
The suggested fix is to restore the enum directly, mirroring the existing 
toPB(BlockPriority). We will submit the fix proposal soon.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to