python-zk / kazoo

Kazoo is a high-level Python library that makes it easier to use Apache Zookeeper.
https://kazoo.readthedocs.io
Apache License 2.0
1.3k stars 386 forks source link

Zookeeper Server's watch residue #733

Open youweisheng opened 9 months ago

youweisheng commented 9 months ago

Expected Behavior

According to Kazoo's documentation, after DataWatch returns False, the registered listener will be destroyed. Not only will Kazoo no longer trigger this listener, but when using wchp to view the zookeeper server, it should also not exist

Actual Behavior

According to Kazoo's documentation, after DataWatch returns False, the registered listener will be destroyed. However, in actual testing, it was found that although Kazoo will no longer trigger the listener, wchp can still find the listener in the zookeeper server

Snippet to Reproduce the Problem

COPY/PASTE the snippet here (omit any sensitive information) from kazoo.client import KazooClient import os import time

zk_client = KazooClient( hosts="127.0.0.1:9639", timeout=4.0, # 连接超时时间 ) zk_client.start() zk_client.create("/pos/test", b"123") watch = zk_client.DataWatch("/pos/test") @watch def watch_node(data, stat): if data: return True return False os.system("echo wchp | nc 127.0.0.1 9639 | grep test")

print("wait...") time.sleep(1) zk_client.delete("/pos/test") time.sleep(1)

os.system("echo wchp | nc 127.0.0.1 9639 | grep test")

Logs with logging in DEBUG mode

COPY/PASTE the result of the snippet here (omit any sensitive information) [root@03f25057-e68e-59ba-b542-1864ef50dcc0 ~]# python3.6 test.py /pos/test wait... /pos/test [root@03f25057-e68e-59ba-b542-1864ef50dcc0 ~]#

Specifications

[root@03f25057-e68e-59ba-b542-1864ef50dcc0 conf]# cat zoo.cfg.dynamic.10000000c3

server.1=10.28.112.50:2888:3888:participant;0.0.0.0:9639