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

Enis Soztutar commented on HBASE-6831:
--------------------------------------

Upon further inspection the root cause boils down to the following sequence of 
events.

HBaseTestingUtility.expireSession() works by getting an already existing 
Zookeeper object, and obtains sessionId from that. 
Then it constructs another Zookeeper() object with the same sessionId and 
passwd, and closes that Zookeeper, which in turn triggers server to mark the 
sessionId as expired. 
{code}
    ZooKeeper zk = nodeZK.getRecoverableZooKeeper().getZooKeeper();
    byte[] password = zk.getSessionPasswd();
    long sessionID = zk.getSessionId();

    ZooKeeper newZK = new ZooKeeper(quorumServers,
        sessionTimeout, EmptyWatcher.instance, sessionID, password);
    newZK.close();
{code}

The race condition occurs, because Zookeeper() constructor starts the 
ClientCnxn.SendThread, but does not wait for connection establishment. 
SendThread.run() does connect to the server if it is not on CLOSING state, and 
changes the state to be CONNECTING. However, Zookeeper.close() sets the state 
as CLOSING, sends a closeSession event to server. Thus if we construct 
Zookeeper() and immediately close it as above, then SendThread.run() and 
ClientCnxn.close() races, and if close() is run first, then we abort the 
connection, and do not even try to establish a connection. 

On Windows, the new thread's execution does not seem to start as fast as linux, 
so we did not run into this previously.

                
> [WINDOWS] HBaseTestingUtility.expireSession() does not expire zookeeper 
> session
> -------------------------------------------------------------------------------
>
>                 Key: HBASE-6831
>                 URL: https://issues.apache.org/jira/browse/HBASE-6831
>             Project: HBase
>          Issue Type: Bug
>    Affects Versions: 0.96.0, 0.94.3
>            Reporter: Enis Soztutar
>            Assignee: Enis Soztutar
>              Labels: windows
>
> TestReplicationPeer fails because it forces the zookeeper session expiration 
> by calling HBaseTestingUtilty.expireSesssion(), but that function fails to do 
> so.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to