HBASE-30038: RefCnt Leak error when caching#7995
Open
dParikesit wants to merge 2 commits intoapache:masterfrom
Open
HBASE-30038: RefCnt Leak error when caching#7995dParikesit wants to merge 2 commits intoapache:masterfrom
dParikesit wants to merge 2 commits intoapache:masterfrom
Conversation
wchevreuil
approved these changes
Mar 28, 2026
vaijosh
reviewed
Mar 30, 2026
| Mockito.verify(cache, Mockito.never()).cacheBlock(Mockito.any(), Mockito.any(), | ||
| Mockito.anyBoolean(), Mockito.anyBoolean()); | ||
| System.gc(); | ||
| Thread.sleep(1000); |
Contributor
There was a problem hiding this comment.
@dParikesit
I think the 1-second assumption might bite us on slower systems and make the test flaky.
What if we wrap this in a loop instead? We could retry up to 15 times with a small delay—that way it succeeds as soon as it's ready rather than relying on luck.
vaijosh
reviewed
Mar 30, 2026
| writeDataBlocksAndCreateIndex(hbw, outputStream, biw); | ||
| assertTrue(biw.getNumLevels() >= 3); | ||
| System.gc(); | ||
| Thread.sleep(1000); |
Contributor
There was a problem hiding this comment.
@dParikesit
I think the 1-second assumption might bite us on slower systems and make the test flaky.
What if we wrap this in a loop instead? We could retry up to 15 times with a small delay—that way it succeeds as soon as it's ready rather than relying on luck.
Contributor
|
Please consider @vaijosh suggestions and also fix spotless issues. |
Contributor
Author
|
Thanks for the suggestions. I'll get back to you after I fix it. |
pankaj72981
approved these changes
Mar 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
JIRA: HBASE-30038
This bug is similar to HBASE-28890
HFileBlock.Writer.getBlockForCaching() creates a ref-counted HFileBlock, and the caller must release its own reference after the cache has taken the ownership it needs.
In HFileWriterImpl.java, the leak happened when shouldCacheBlock() returned before cacheFormatBlock.release() ran.
In HFileBlockIndex.java, the intermediate-index path cached blockForCaching but never released the reference at all.
Because these blocks can be backed by pooled off-heap ByteBuffs, repeated HFile writes could steadily drain allocator buffers and effectively leak memory, even though the blocks were only meant to live long enough to be considered for cache-on-write.