openinx commented on a change in pull request #242: HBASE-22422 Retain an 
ByteBuff with refCnt=0 when getBlock from LRUCache
URL: https://github.com/apache/hbase/pull/242#discussion_r284963100
 
 

 ##########
 File path: 
hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderImpl.java
 ##########
 @@ -1499,15 +1504,14 @@ public HFileBlock readBlock(long dataBlockOffset, long 
onDiskBlockSize,
         BlockType.BlockCategory category = 
hfileBlock.getBlockType().getCategory();
 
         // Cache the block if necessary
-        AtomicBoolean cachedRaw = new AtomicBoolean(false);
         cacheConf.getBlockCache().ifPresent(cache -> {
           if (cacheBlock && cacheConf.shouldCacheBlockOnRead(category)) {
-            cachedRaw.set(cacheConf.shouldCacheCompressed(category));
-            cache.cacheBlock(cacheKey, cachedRaw.get() ? hfileBlock : unpacked,
+            cache.cacheBlock(cacheKey,
+              cacheConf.shouldCacheCompressed(category) ? hfileBlock : 
unpacked,
               cacheConf.isInMemory());
           }
         });
-        if (unpacked != hfileBlock && !cachedRaw.get()) {
+        if (unpacked != hfileBlock) {
 
 Review comment:
   Because no matter we put the compressedBlock or the uncompressedBlock into 
BlockCache, the BlockCache will retain the cached block (increasing its 
refCnt).  So here,  we only need to consider whether if the uncompressedBlock 
is excatly the compressedBlock, if not then just release the compressedBlock 
because the RPC will reference this uncompressedBlock. 
   It's a bug which was introduced in HBASE-22005. so made a fix here.  
   Will provide a UT for this.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to