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_r287903698
##########
File path:
hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/BlockCacheUtil.java
##########
@@ -230,6 +230,9 @@ public static boolean
shouldReplaceExistingCacheBlock(BlockCache blockCache,
BlockCacheKey cacheKey, Cacheable newBlock) {
// NOTICE: The getBlock has retained the existingBlock inside.
Cacheable existingBlock = blockCache.getBlock(cacheKey, false, false,
false);
+ if (existingBlock == null) {
Review comment:
Yes, see the LruBlockCache#cacheBlock:
```
LruCachedBlock cb = map.get(cacheKey);
if (cb != null && !BlockCacheUtil.shouldReplaceExistingCacheBlock(this,
cacheKey, buf)) {
return;
}
```
The existence pre-check and accessing block in
shouldReplaceExistingCacheBlock is not atomic op. so if any eviction happen
between them, the NPE will happen. I added a UT
testMultiThreadGetAndEvictBlock to address 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