I don't believe ZooKeeper watches maintain a memory of events that occurred 
while you were disconnected. It's been a very long time since I looked at this 
code but my memory is that if you are disconnected you will miss events. Not 
just with persistent watches but with any watches.

-Jordan

> On Jul 25, 2025, at 2:22 AM, Li Wang <li4w...@gmail.com> wrote:
> 
> Hello,
> 
> I wonder if anyone knows whether persistent recursive watch ensures that
> the client receives notifications for any changes that occurred while
> disconnected?
> 
> The feature was introduced in
> https://issues.apache.org/jira/browse/ZOOKEEPER-1416.
> 
> Following the code, it looks like it only re-registers the watches but
> doesn't check if any changes have occurred and need to be notified upon
> reconnecting.
> 
> I wonder if anyone has any knowledge and insight on this. Any
> response would be appreciated.
> 
> 
> Code snippet in DataTree.setWatches()
> =============================
> 
> for (String path : persistentWatches) {
>            this.childWatches.addWatch(path, watcher,
> WatcherMode.PERSISTENT);
>            this.dataWatches.addWatch(path, watcher,
> WatcherMode.PERSISTENT);
>        }
>        for (String path : persistentRecursiveWatches) {
>            this.dataWatches.addWatch(path, watcher,
> WatcherMode.PERSISTENT_RECURSIVE);
>        }
> 
> https://github.com/apache/zookeeper/blob/master/zookeeper-server/src/main/java/org/apache/zookeeper/server/DataTree.java#L1492-L1529
> 
> 
> Thanks
> 
> Li

Reply via email to