bonifaido / rust-zookeeper

Pure Rust library for Apache ZooKeeper built on MIO
MIT License
206 stars 46 forks source link

Lost watch events #98

Closed madtrick closed 1 year ago

madtrick commented 1 year ago

Hi,

In my local setup I have seen several times how watch events seem to be lost by the Zookeper client. This is the code where I watch for events:

fn main () {
    let zk = ZooKeeper::connect("localhost:2181", Duration::from_secs(15), LoggingWatcher).unwrap();

    zk.add_watch(
        "/nodes",
        AddWatchMode::PersistentRecursive,
        |event: WatchedEvent| {
            println!("Event {:?}, path {:?}", event, event.path);
        },
    )
    .unwrap();

    loop {
        thread::sleep(Duration::from_secs(1800));
    }
}

And I'm running zookeeper via docker compose

  zookeeper:
    image: zookeeper
    restart: always
    ports:
      - 2181:2181
  zookeeper-cli:
    image: zookeeper
    command: zkCli.sh -server zookeeper

If I watch events from the Zookeeper CLI I see all of them, however some are not "seen" by the Zookeeper rust client. For example, in the screenshot below you can see a NodeCreated and NodeDeleted for the path /nodes/node0000000079 in the CLI.

image

But I only get one watch in rust

image

Is this a bug in the Zookeeper rust client or should I be looking elsewhere?

madtrick commented 1 year ago

Closed in favour of https://github.com/bonifaido/rust-zookeeper/issues/99