hbase-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nicolas Liochon (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HBASE-11685) Incr/decr on the reference count of HConnectionImplementation need be atomic
Date Wed, 13 Aug 2014 09:26:12 GMT

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

Nicolas Liochon commented on HBASE-11685:
-----------------------------------------

Actually, there is no bug here: increments and decrements are done in ??synchronized (CONNECTION_INSTANCES)??
, so they are already atomic.  There is no need to use atomicInteger here (a comment on the
sync requirement would be welcome however :-) ) 

The exception is the finalize (before and after the patch): there is a set without synchronization.
At the end, I would propose to just remove the finalize..  It's safer and makes the code simpler
to read. We cannot rely on a finalize to free resources anyway.

> Incr/decr on the reference count of HConnectionImplementation need be atomic 
> -----------------------------------------------------------------------------
>
>                 Key: HBASE-11685
>                 URL: https://issues.apache.org/jira/browse/HBASE-11685
>             Project: HBase
>          Issue Type: Bug
>          Components: Client
>            Reporter: Liu Shaohui
>            Assignee: Liu Shaohui
>            Priority: Minor
>             Fix For: 2.0.0
>
>         Attachments: HBASE-11685-trunk-v1.diff, HBASE-11685-trunk-v2.diff, HBASE-11685-trunk-v3.diff,
HBASE-11685-trunk-v4.diff, HBASE-11685-trunk-v5.diff, HBASE-11685-trunk-v6.diff
>
>
> Currently, the incr/decr operation on the ref count of HConnectionImplementation are
not atomic. This may cause that the ref count always be larger than 0 and  the connection
never be closed.
> {code}
>     /**
>      * Increment this client's reference count.
>      */
>     void incCount() {
>       ++refCount;
>     }
>     /**
>      * Decrement this client's reference count.
>      */
>     void decCount() {
>       if (refCount > 0) {
>         --refCount;
>       }
>     }
> {code}



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message