You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@zookeeper.apache.org by Yuhan Zhang <yz...@onescreen.com> on 2011/09/23 23:49:41 UTC

SessionExpiredException. help please

Hi all,

I set the sessionTimeout value to be "Integer.MAX_VALUE" to the constructor
as
 zooKeeper = new ZooKeeper(host, Integer.MAX_VALUE, this);
but reached an "session expired" exception when requesting a create
operation twice on the following line:

lockPath = zooKeeper.create( lockFolder + "/0", new byte[0],
Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL_SEQUENTIAL);

Exception:
org.apache.zookeeper.KeeperException$SessionExpiredException :
KeeperErrorCode = Session expired for /_lock/0


why does this happen? could anyone give some advice?


Thank you.

Yuhan

Re: SessionExpiredException. help please

Posted by Patrick Hunt <ph...@apache.org>.
On Fri, Sep 23, 2011 at 4:46 PM, Yuhan Zhang <yz...@onescreen.com> wrote:
> also, is auto-reconnection available through zooKeeper API?
> I'd like to keep a very long session/connection. Is this a good practice
> with zooKeeper?

The client will always try to reconnect if it becomes disconnected,
however not if the session becomes expired. That page I linked on
sessions provides details, as does the FAQ.
https://cwiki.apache.org/confluence/display/ZOOKEEPER/FAQ

Patrick

Re: SessionExpiredException. help please

Posted by Yuhan Zhang <yz...@onescreen.com>.
Hi Patrick,

Thanks for the remark. I will look into the timeout limit setting.

also, is auto-reconnection available through zooKeeper API?
I'd like to keep a very long session/connection. Is this a good practice
with zooKeeper?

Thank you.

Yuhan

On Fri, Sep 23, 2011 at 3:24 PM, Patrick Hunt <ph...@apache.org> wrote:

> Take a look at the docs, in particular information on sessions:
>
> http://zookeeper.apache.org/doc/r3.3.3/zookeeperProgrammers.html#ch_zkSessions
> "One of the parameters to the ZooKeeper client library call to create
> a ZooKeeper session is the session timeout in milliseconds. The client
> sends a requested timeout, the server responds with the timeout that
> it can give the client. The current implementation requires that the
> timeout be a minimum of 2 times the tickTime (as set in the server
> configuration) and a maximum of 20 times the tickTime. The ZooKeeper
> client API allows access to the negotiated timeout."
>
> You can change the max limit imposed by the server, see here:
>
> http://zookeeper.apache.org/doc/r3.3.3/zookeeperAdmin.html#sc_advancedConfiguration
>
> You should be able to see in the logs what the negotiated session timeout
> was.
>
> This likely indicates that your client is pausing for long periods of
> time -- the most common case is GC pause. See the troubleshooting
> guide.
> https://cwiki.apache.org/confluence/display/ZOOKEEPER/Troubleshooting
> try turning on verbose GC logging to verify.
>
> Patrick
>
> On Fri, Sep 23, 2011 at 2:49 PM, Yuhan Zhang <yz...@onescreen.com> wrote:
> > Hi all,
> >
> > I set the sessionTimeout value to be "Integer.MAX_VALUE" to the
> constructor
> > as
> >  zooKeeper = new ZooKeeper(host, Integer.MAX_VALUE, this);
> > but reached an "session expired" exception when requesting a create
> > operation twice on the following line:
> >
> > lockPath = zooKeeper.create( lockFolder + "/0", new byte[0],
> > Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL_SEQUENTIAL);
> >
> > Exception:
> > org.apache.zookeeper.KeeperException$SessionExpiredException :
> > KeeperErrorCode = Session expired for /_lock/0
> >
> >
> > why does this happen? could anyone give some advice?
> >
> >
> > Thank you.
> >
> > Yuhan
> >
>

Re: SessionExpiredException. help please

Posted by Patrick Hunt <ph...@apache.org>.
Take a look at the docs, in particular information on sessions:
http://zookeeper.apache.org/doc/r3.3.3/zookeeperProgrammers.html#ch_zkSessions
"One of the parameters to the ZooKeeper client library call to create
a ZooKeeper session is the session timeout in milliseconds. The client
sends a requested timeout, the server responds with the timeout that
it can give the client. The current implementation requires that the
timeout be a minimum of 2 times the tickTime (as set in the server
configuration) and a maximum of 20 times the tickTime. The ZooKeeper
client API allows access to the negotiated timeout."

You can change the max limit imposed by the server, see here:
http://zookeeper.apache.org/doc/r3.3.3/zookeeperAdmin.html#sc_advancedConfiguration

You should be able to see in the logs what the negotiated session timeout was.

This likely indicates that your client is pausing for long periods of
time -- the most common case is GC pause. See the troubleshooting
guide.
https://cwiki.apache.org/confluence/display/ZOOKEEPER/Troubleshooting
try turning on verbose GC logging to verify.

Patrick

On Fri, Sep 23, 2011 at 2:49 PM, Yuhan Zhang <yz...@onescreen.com> wrote:
> Hi all,
>
> I set the sessionTimeout value to be "Integer.MAX_VALUE" to the constructor
> as
>  zooKeeper = new ZooKeeper(host, Integer.MAX_VALUE, this);
> but reached an "session expired" exception when requesting a create
> operation twice on the following line:
>
> lockPath = zooKeeper.create( lockFolder + "/0", new byte[0],
> Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL_SEQUENTIAL);
>
> Exception:
> org.apache.zookeeper.KeeperException$SessionExpiredException :
> KeeperErrorCode = Session expired for /_lock/0
>
>
> why does this happen? could anyone give some advice?
>
>
> Thank you.
>
> Yuhan
>