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?
…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. |
| lock.readLock().unlock(); | ||
| } | ||
| if (failedBucketEntryRead) { | ||
| removeFailedBucketEntry(bucketEntry); |
There was a problem hiding this comment.
We are modifying behaviour with this. Now, in the event of an io read error, even if checkIOErrorIsTolerated ignores the error, we will evict the block?
| }); | ||
| } | ||
|
|
||
| private BlockCacheKey findBackingMapKey(BucketEntry bucketEntry) { |
There was a problem hiding this comment.
Rather than iterating the whole backingMap, can we use similar logic from getBlockForReference to resolve the reference key? Please make the common code reusable.
| LOG.error("IO errors duration time has exceeded " + ioErrorsTolerationDuration | ||
| + "ms, disabling cache, please check your IOEngine"); | ||
| disableCache(); | ||
| disableCache(false); |
There was a problem hiding this comment.
Why we wouldn't want to persist the backingMap here?
| LOG.info("Shutdown bucket cache: IO persistent=" + ioEngine.isPersistent() | ||
| + "; path to write=" + persistencePath); | ||
| if (ioEngine.isPersistent() && persistencePath != null) { | ||
| private void cleanupCache(boolean persistOnCleanup) { |
There was a problem hiding this comment.
nit: Let's call this 'cleanupBackingMap' or 'cleanupCacheIndex' to avoid confusion.
For file based bucket cache, backingMap can grow quite large and traversing it to release references can be costly. Should we worry about this only when shutting down BC after exceeding IO errors thresholds, and ignoring it when doing RS 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: