kaisun2000 commented on a change in pull request #1035:
URL: https://github.com/apache/helix/pull/1035#discussion_r435010689
##########
File path:
helix-core/src/main/java/org/apache/helix/manager/zk/CallbackHandler.java
##########
@@ -539,7 +539,15 @@ private void subscribeChildChange(String path,
NotificationContext.Type callback
logger.debug(_manager.getInstanceName() + " subscribes child-change.
path: " + path
+ ", listener: " + _listener);
}
- _zkClient.subscribeChildChanges(path, this);
+ // In the lifecycle of CallbackHandler, INIT is the first stage of
registration of watch.
+ // For some usage case such as current state, the path can be created
later. Thus we would
+ // install watch anyway event the path is not yet created.
+ // Later, CALLBACK type, the CallbackHandler already registered the
watch and knows the
+ // path was created. Here, to avoid leaking path in ZooKeeper server, we
would not let
+ // CallbackHandler to install exists watch, namely watch for path not
existing.
+ // Note when path is removed, the CallbackHanler would remove itself
from ZkHelixManager too
+ // to avoid leaking a CallbackHandler.
+ _zkClient.subscribeChildChanges(path, this, callbackType != Type.INIT);
Review comment:
If CallbackType is CALLBACK, ignore it is just want we want. That is
exactly the case of async removal of a parent current state. This would result
in hanldeChildren() first code path, removing the callbackhandler from the
zkhelixmanager.
If CallbackType is INIT, it would not fail.
So let us add a debug log for general case. Only failure case, info log. As
general case would be too much.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]