HBASE-30285 BucketCache shutdown/disable does not release backingMap-owned BucketEntry references#8469
HBASE-30285 BucketCache shutdown/disable does not release backingMap-owned BucketEntry references#8469mwkang wants to merge 2 commits into
Conversation
|
We’d better keep the Jira title and commit message consistent, thanks! |
wchevreuil
left a comment
There was a problem hiding this comment.
Thank you for submitting this fix. I have some concerns about this, however.
Considering we call BucketCache.shutdown normally when stopping a RS process, the reference count leak here wouldn't be a big problem (the jvm process will be over soon). The introduction of locks on a hot code path, though, could have a performance impact.
Have we done any performance benchmark comparison for validating this change is not introducing a noticeable performance impact?
| // the cache map state might differ from the actual cache. If we reach this block, | ||
| // we should remove the cache key entry from the backing map | ||
| backingMap.remove(key); | ||
| fileNotFullyCached(key, bucketEntry); |
There was a problem hiding this comment.
Where are we tracking the file as not fully cached now? This can affect the cache aware load balancer proper functioning.
There was a problem hiding this comment.
Good catch. In the revised patch, the failed-read path now releases the offset read lock first, finds the actual key stored in backingMap, and removes the entry under its offset write lock.
After a successful conditional removal, it calls blockEvicted(cacheKey, bucketEntry, true, false), which invokes fileNotFullyCached for persistent IO engines. This keeps the file and region cache metadata used by the cache-aware load balancer consistent.
I also added regression tests for both direct and reference-file lookups.
…owned BucketEntry references
|
The benchmark concern was valid for the previous revision, which added lifecycle locking around cacheBlock and writer-queue publication. Compared with master, cacheBlock and the normal writer-queue path are unchanged. The leak is also reachable when IOEngine read, write, or sync errors persist beyond the configured tolerance duration: BucketCache disables itself while the RegionServer JVM continues running. It is therefore not limited to process shutdown. |
See HBASE-30285.
BucketCache.backingMapowns the initial reference of eachBucketEntry.The existing shutdown and disable paths discard map entries without releasing these references, so their reference counts may never reach zero.
This change:
backingMapentriesbackingMapowner reference under its offset write lockblockEvicted, preserving file and region cache metadataThe tests cover: