apache-zookeeperapache-curator

When does curator lib does retry


I was under the impression that curator lib will do the retry for all the Zookeeper operations even if the session is lost. I was simulating a case where I had created a node and then set some data to that node. Then while retrieving the data i killed the session. I see that the curator is able to reconnect to the session but I thought it will also retry and get the data which was not the case. Is there any documentation as to when exactly and for which operations curator does a retry.

Code that watches the node:

getAsyncCuratorFramework(curatorFramework)
            .watched()
            .checkExists()
            .forPath(fullNodePath)
            .event()
            .toCompletableFuture()
            .get(jobTimeoutDO.getDuration(), jobTimeoutDO.getTimeUnit());

Now I am simulating a test where I am watching an Ephemeral node for node delete event and I schedule the following call in between:

KillSession.kill

Since the session was killed the node will be removed and curator will try to establish the connection again. All of this works fine and as expected. But I also thought that the curator will retry and watch the node again ofcourse if the node does not exists it might throw an exception but I do create a node again.

Just wanted to confirm in the above scenario will the curator not retry. BTW it throws the following exception:

AsyncEventException

Solution

  • But I also thought that the curator will retry and watch the node again

    That's not how retries work. Retries in Curator retry individual ZooKeeper operations. They are not a high level feature and will not reset watches for you. What you are looking for is one of Curator's high level recipes that manage a ZNode. Have a look at PersistentNode or NodeCache.