You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@curator.apache.org by 阳海涛 <ya...@xinguodu.com> on 2015/09/10 11:09:57 UTC

i think there maybe has a bug in curator framework all version,contians the lasest version(2.8.0),hope to get your reply

  hello,when i use the curatorFramework connnect to zookeeper successed,if the Network instability,it's occured org.apache.zookeeper.KeeperException$SessionExpiredException:****   error  frequently.and the worst

case is the curator client could not reconnected the zookeeper server again,unless i restart my application.so i read the curator source code,i think there has a bug.

curator version:2.8.0

code Class:org.apache.curator.HandleHolder

code method:

 private void internalClose() throws Exception
    {
        try
        {
            ZooKeeper zooKeeper = (helper != null) ? helper.getZooKeeper() : null;
            if ( zooKeeper != null )
            {
                Watcher dummyWatcher = new Watcher()
                {
                    @Override
                    public void process(WatchedEvent event)
                    {
                    }
                };
                zooKeeper.register(dummyWatcher);   // clear the default watcher so that no new events get processed by mistake

              //TODO:i think we should set ConnectionState isConnected=false in here by manualHand,in case of
              //the old zookeeper instance notified a old event in the interval of dummyWatcher not registed

                zooKeeper.close();
            }
        }
        catch ( InterruptedException dummy )
        {
            Thread.currentThread().interrupt();
        }
    }


hello, everyone,please see the red code,

first,ConnectionState is isConnected=false,when the red color code will excute but not excuted , the old zookeeper instance connect to zookeeper server successed, so  ConnectionState is isConnected=true,and then the red code begin excute,but becuase of network not used again, the new zookeeper instance not success to connect zookeerper server,so i think   ConnectionState is isConnected=true is a invalid state, and the invalid state will cause curator framework never connect to zookeeper server.please see the code of down:

code Class:org.apache.curator.ConnectionState

code method:

 ZooKeeper getZooKeeper() throws Exception
    {
        if ( SessionFailRetryLoop.sessionForThreadHasFailed() )
        {
            throw new SessionFailRetryLoop.SessionFailedException();
        }

        Exception exception = backgroundExceptions.poll();
        if ( exception != null )
        {
            tracer.get().addCount("background-exceptions", 1);
            throw exception;
        }

        boolean localIsConnected = isConnected.get();
        if ( !localIsConnected )
        {
            checkTimeouts();
        }

        return zooKeeper.getZooKeeper();
    }

   please see the red code, becuase of the isConnected=true(invalid state),so its cause new reset zookeeper instance again.






  本邮件所包含或其随附的信息可能属于保密信息,如果您并非本邮件指明的收件方,请将您拥有的本邮件及其所有备份(包括所有附件)删除并销毁,在此特提请您注意不得泄露、复制或散发本邮件。
  The information contained or attached in this email may be confidential. If you are not the appointed recipient of this email, please delete and destroy all copies (including all the attachments) in your possession. And you are hereby notified that any disclosure, duplication or dissemination of this email, is expressly forbidden.

Re: i think there maybe has a bug in curator framework all version,contians the lasest version(2.8.0),hope to get your reply

Posted by Jordan Zimmerman <jo...@jordanzimmerman.com>.
It certainly looks possible. Please open an issue in Jira for this so that it can be tracked.

-Jordan



On September 10, 2015 at 7:14:44 AM, 阳海涛 (yanghaitao@xinguodu.com) wrote:


hello,when i use the curatorFramework connnect to zookeeper successed,if the Network instability,it's occured org.apache.zookeeper.KeeperException$SessionExpiredException:**** error frequently.and the worst  

case is the curator client could not reconnected the zookeeper server again,unless i restart my application.so i read the curator source code,i think there has a bug.  

curator version:2.8.0  

code Class:org.apache.curator.HandleHolder  

code method:  

private void internalClose() throws Exception  
{  
try  
{  
ZooKeeper zooKeeper = (helper != null) ? helper.getZooKeeper() : null;  
if ( zooKeeper != null )  
{  
Watcher dummyWatcher = new Watcher()  
{  
@Override  
public void process(WatchedEvent event)  
{  
}  
};  
zooKeeper.register(dummyWatcher); // clear the default watcher so that no new events get processed by mistake  

//TODO:i think we should set ConnectionState isConnected=false in here by manualHand,in case of  
//the old zookeeper instance notified a old event in the interval of dummyWatcher not registed  

zooKeeper.close();  
}  
}  
catch ( InterruptedException dummy )  
{  
Thread.currentThread().interrupt();  
}  
}  


hello, everyone,please see the red code,  

first,ConnectionState is isConnected=false,when the red color code will excute but not excuted , the old zookeeper instance connect to zookeeper server successed, so ConnectionState is isConnected=true,and then the red code begin excute,but becuase of network not used again, the new zookeeper instance not success to connect zookeerper server,so i think ConnectionState is isConnected=true is a invalid state, and the invalid state will cause curator framework never connect to zookeeper server.please see the code of down:  

code Class:org.apache.curator.ConnectionState  

code method:  

ZooKeeper getZooKeeper() throws Exception  
{  
if ( SessionFailRetryLoop.sessionForThreadHasFailed() )  
{  
throw new SessionFailRetryLoop.SessionFailedException();  
}  

Exception exception = backgroundExceptions.poll();  
if ( exception != null )  
{  
tracer.get().addCount("background-exceptions", 1);  
throw exception;  
}  

boolean localIsConnected = isConnected.get();  
if ( !localIsConnected )  
{  
checkTimeouts();  
}  

return zooKeeper.getZooKeeper();  
}  

please see the red code, becuase of the isConnected=true(invalid state),so its cause new reset zookeeper instance again.  






本邮件所包含或其随附的信息可能属于保密信息,如果您并非本邮件指明的收件方,请将您拥有的本邮件及其所有备份(包括所有附件)删除并销毁,在此特提请您注意不得泄露、复制或散发本邮件。  
The information contained or attached in this email may be confidential. If you are not the appointed recipient of this email, please delete and destroy all copies (including all the attachments) in your possession. And you are hereby notified that any disclosure, duplication or dissemination of this email, is expressly forbidden.