多次调用 ZooKeeper node watch

ZooKeeper node watch called mutiple times

我偶然发现了一个节点监视被多次调用的场景,尽管文档说明了哪些是一次性调用:

  1. 在节点上设置监视。
  2. 使会话过期。
  3. 手表是用 ZOO_SESSION_EVENT 和 ZOO_CONNECTING_STATE 调用的。
  4. 此后手表再次调用 ZOO_SESSION_EVENT 和 ZOO_EXPIRED_SESSION_STATE。

这是预期的行为吗?我是否遗漏了文档中的内容?

回答我自己的问题,我在文档中找到了这个:

When you disconnect from a server (for example, when the server fails), you will not get any watches until the connection is reestablished. For this reason session events are sent to all outstanding watch handlers. Use session events to go into a safe mode: you will not be receiving events while disconnected, so your process should act conservatively in that mode.