[ 
https://issues.apache.org/jira/browse/HBASE-13301?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

zhangduo updated HBASE-13301:
-----------------------------
    Attachment: HBASE-13301_v3.patch

[~ndimiduk] Yes, I tried it on every branch. Just change 
'backingMap.remove(cacheKey, bucketEntry)' back to 
'bucketEntry.equals(backingMap.remove(cacheKey))' in BucketCache.evictBlock, 
the test will fail every time.

And for the sleep in testcase...
For the evictThread, it is not easy to add a count down latch since we expect 
the thread to be blocked on the IdLock. And for the BucketCache.cacheBlock, it 
is a simple queue based async operation, I think it is not worth to add more 
logic other than a simple sleep wait, it is fast...

I extracted the cacheAndWait operation to a method and add some comments to 
explain the reason. And I added a method in IdLock to check the number of 
waiters who are waiting on the given id and use this method to confirm the 
evictThread is blocked on the IdLock.

Thanks.

> Possible memory leak in BucketCache
> -----------------------------------
>
>                 Key: HBASE-13301
>                 URL: https://issues.apache.org/jira/browse/HBASE-13301
>             Project: HBase
>          Issue Type: Bug
>          Components: BlockCache
>            Reporter: zhangduo
>            Assignee: zhangduo
>             Fix For: 2.0.0, 1.1.0, 0.98.13, 1.0.2
>
>         Attachments: HBASE-13301-0.98.patch, HBASE-13301-branch-1.0.patch, 
> HBASE-13301-branch-1.0.patch, HBASE-13301-branch-1.patch, 
> HBASE-13301-testcase.patch, HBASE-13301-testcase_v1.patch, HBASE-13301.patch, 
> HBASE-13301_v1.patch, HBASE-13301_v2.patch, HBASE-13301_v3.patch
>
>
> {code:title=BucketCache.java}
> public boolean evictBlock(BlockCacheKey cacheKey) {
>       ...
>       if (bucketEntry.equals(backingMap.remove(cacheKey))) {
>         bucketAllocator.freeBlock(bucketEntry.offset());
>         realCacheSize.addAndGet(-1 * bucketEntry.getLength());
>         blocksByHFile.remove(cacheKey.getHfileName(), cacheKey);
>         if (removedBlock == null) {
>           this.blockNumber.decrementAndGet();
>         }
>       } else {
>         return false;
>       }
>       ...
> {code}
> I think the problem is here. We remove a BucketEntry that should not be 
> removed by us, but we do not put it back and also do not do any clean up.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to