virajjasani commented on a change in pull request #3407:
URL: https://github.com/apache/hbase/pull/3407#discussion_r666482218
##########
File path:
hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/LruAdaptiveBlockCache.java
##########
@@ -646,14 +639,16 @@ private long updateSizeMetrics(LruCachedBlock cb, boolean
evict) {
@Override
public Cacheable getBlock(BlockCacheKey cacheKey, boolean caching, boolean
repeat,
boolean updateCacheMetrics) {
- LruCachedBlock cb = map.computeIfPresent(cacheKey, (key, val) -> {
- // It will be referenced by RPC path, so increase here. NOTICE: Must do
the retain inside
- // this block. because if retain outside the map#computeIfPresent, the
evictBlock may remove
- // the block and release, then we're retaining a block with refCnt=0
which is disallowed.
- // see HBASE-22422.
- val.getBuffer().retain();
- return val;
- });
+ LruCachedBlock cb = map.get(cacheKey);
+ if (cb != null) {
+ try {
+ cb.getBuffer().retain();
Review comment:
I think for possibility#2 in above, we stand a chance where buffer with
non-zero refCount is not in the cache. I see, let me see what alternatives we
have for this case.
Although I still think that same case can happen even today.
getBlock does retain() which will bring refCount of BB to 2, while getBlock
is busy updating stats, eviction thread can evict block from cache and it does
release() which will bring refCount of BB to 1. So even in this case, we can
positive refCount buffer which is evicted from cache.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]