twitter/scala-zookeeper-client — Issue #5: Ephemeral znodes on close throw uncaught exception
Author: dataferret
Created: 2011-11-25 04:52:35+00:00
State: open

Hi,

For ephemeral znodes, it looks like ZooKeeper triggers the deletedData watch sometimes late.

zookeeper.ClientCnxn - Error while calling watcher
org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /test/cluster:2124/service/sim/n-0000000001
at org.apache.zookeeper.KeeperException.create(KeeperException.java:90)
at org.apache.zookeeper.KeeperException.create(KeeperException.java:42)
at org.apache.zookeeper.ZooKeeper.exists(ZooKeeper.java:809)
at com.twitter.zookeeper.ZooKeeperClient.deletedData$1(ZooKeeperClient.scala:179)
at com.twitter.zookeeper.ZooKeeperClient$$anon$2.process(ZooKeeperClient.scala:194)
at org.apache.zookeeper.ClientCnxn$EventThread.processEvent(ClientCnxn.java:530)
at org.apache.zookeeper.ClientCnxn$EventThread.run(ClientCnxn.java:506)

To reproduce, you can create an ephem znode and then call zk.close() It doesn't occur always, but often enough. I'm getting around it by adding a catch for KeeperException.ConnectionLossException where it's doing zk.exists (line 179: ZooKeeperClient.scala) You might be able to get around it by calling zk.isAlive as well.

P.S. I'm not deleting the node before calling close.