[
https://issues.apache.org/jira/browse/HBASE-11685?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14092358#comment-14092358
]
Liu Shaohui commented on HBASE-11685:
-------------------------------------
[~apurtell]
{quote}
I really think we need to preserve the earlier logic
{quote}
I'm sorry that i didn't get your meanings? is the earlier logic just the
current codebase?
The current codebase, the connection may never be closed out for two threads
concurrently decrease the ref counter.
And the following code just hides the the possible bug that there are more
decCount ops than incCount ops in the code.
{code}
void decCount() {
if (refCount > 0) {
--refCount;
}
}
{code}
In my opinion,we should expose the bug as early as possible.
(1) When the count goes negative, we should print warn log or throw an
exception.
(2) When someone forgets to call the decCount, and the ref count always be
positive , the connection never be closed. we can find this problem from the
output of jstack.
I think the change doesn't introduce a new class of bug.
> 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
>
>
> 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)