[ 
https://issues.apache.org/jira/browse/HBASE-5088?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13174646#comment-13174646
 ] 

Lars Hofhansl edited comment on HBASE-5088 at 12/22/11 6:35 AM:
----------------------------------------------------------------

ConcurrentSkipListMap does not appear to have this problem as a {head|tail}Map 
just maps put/get operations back to the original map. Maybe we can do the same 
approach here.

Cannot use ConcurrentSkipListMap directly as SoftValueSortedMap specifically 
stores SoftReferences to the values... Although I am personally not a big fan 
of this. Either we cache stuff or not. If there is memory pressure and the JVM 
removes the object referred to by the soft references, we generate even more 
new garbage when we miss the cache and have to reacquire the object.

Looks like SoftValueSortedMap.headMap() is buggy, we should throw 
UnsupportedOperation or fix it. Fixing it would mean to keep a reference to the 
original map and use that synchronize in the headMap (which means we need to 
return a special inner class), or to materialize the headmap in a copy, or do 
what ConcurrentSkipListMap does and map the API operations back to the original 
map.

                
      was (Author: lhofhansl):
    ConcurrentSkipListMap does not appear to have this problem as a 
{head|tail}Map just maps put/get operations back to the original map. Maybe we 
can do the same approach here.

Cannot use ConcurrentSkipListMap as SoftValueSortedMap specifically stores 
SoftReferences to the values... Although I am personally not a big fan of this. 
Either we cache stuff or not. If there is memory pressure and the JVM removes 
the object referred to by the soft references, we generate even more new 
garbage when we miss the cache and have to reacquire the object.

Looks like SoftValueSortedMap.headMap() is buggy, we should throw 
UnsupportedOperation or fix it. Fixing it would mean to keep a reference to the 
original map and use that synchronize in the headMap (which means we need to 
return a special inner class), or to materialize the headmap in a copy, or do 
what ConcurrentSkipListMap does and map the API operations back to the original 
map.

                  
> A concurrency issue on SoftValueSortedMap
> -----------------------------------------
>
>                 Key: HBASE-5088
>                 URL: https://issues.apache.org/jira/browse/HBASE-5088
>             Project: HBase
>          Issue Type: Bug
>          Components: client
>    Affects Versions: 0.90.4, 0.94.0
>            Reporter: Jieshan Bean
>            Assignee: Jieshan Bean
>
> SoftValueSortedMap is backed by a TreeMap. All the methods in this class are 
> synchronized. If we use this method to add/delete elements, it's ok.
> But in HConnectionManager#getCachedLocation, it use headMap to get a view 
> from SoftValueSortedMap#internalMap. Once we operate 
> on this view map(like add/delete) in other threads, a concurrency issue may 
> occur.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to