Biju Nair created HBASE-22305:
---------------------------------
Summary: LRU Block cache may not retain recently used blocks
during eviction
Key: HBASE-22305
URL: https://issues.apache.org/jira/browse/HBASE-22305
Project: HBase
Issue Type: Improvement
Components: BlockCache
Reporter: Biju Nair
During block
[eviction|https://github.com/apache/hbase/blob/8ec93ea193f6765fd2639ce851ef8cac7df3f555/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/LruBlockCache.java#L628-L648],
LRU block cache creates LruCachedBlockQueue and adds blocks from the
Concurrent Hash Map (Cache) to identify the ones for retention. During the
[add|https://github.com/apache/hbase/blob/8ec93ea193f6765fd2639ce851ef8cac7df3f555/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/LruCachedBlockQueue.java#L67]
, entries from the Cache (Hash map) are added to the queue without any check
on the block access time until total size of blocks added to the queue reaches
the max size for the queue. After the max size is reached, only blocks with
[access time greater than the access time of last block in the queue is added
from "Cache" to the
queue|https://github.com/apache/hbase/blob/8ec93ea193f6765fd2639ce851ef8cac7df3f555/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/LruCachedBlockQueue.java#L73].
But as path of Cache operation, when there is a cache hit the [access time of
the block is changed to the latest
time|https://github.com/apache/hbase/blob/8ec93ea193f6765fd2639ce851ef8cac7df3f555/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/LruBlockCache.java#L507].
While iterating through Cache and adding blocks to the LruCachedBlockQueue, if
the last element added when the queue size reached max has a access time
greater than the rest of the blocks in Cache Hash Map, then remaining blocks
will not be added to the queue to be considered for retention even though they
have access time greater than other blocks added to the queue before the last
one.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)