[
https://issues.apache.org/jira/browse/ZOOKEEPER-1910?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13976512#comment-13976512
]
Rakesh R commented on ZOOKEEPER-1910:
-------------------------------------
Thanks [~rgs] for the comments.
{quote}Why do we need to send a RemoveWatches request to the server with
remove=false if that is essentially a no-op? Just to check if the watch stills
exists in the server before we remove it on the client? It could still race, so
I think that if all we want to do is unregister a watcher locally we should do
it without paying a round-trip to the server.
{quote}
IMHO sending request to the server will help to do an orderly execution and
will help in handling the packets in-flight cases. Anyway we can't completely
avoid server call, so I think better to do a call to server with remove=false
rather than having a logic to check watcher exists in server and remove it from
the client. In another way if we see removeWatches() api, it is also doing the
watcher check in the server right. Does this make sense to you ?
Actually I was thinking to remove the pre-valiadtion check before sending the
packet, because we already have server side validation. If agrees, I'll remove
this pre-validation when preparing another patch.
{code}
// Validating the existence of watcher.
watchManager.containsWatcher(clientPath, watcher, watcherType);
{code}
bq.Also, about the naming, do you think that renaming removeWatches to
removeWatchers would still be confusing?
I feel removeWatches api name is OK. I referred
https://zookeeper.apache.org/doc/trunk/zookeeperProgrammers.html#ch_zkWatches.
Probably [~michim] can help us:)
> RemoveWatches wrongly removes the watcher if multiple watches exists on a path
> ------------------------------------------------------------------------------
>
> Key: ZOOKEEPER-1910
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-1910
> Project: ZooKeeper
> Issue Type: Bug
> Reporter: Rakesh R
> Assignee: Rakesh R
> Fix For: 3.5.0
>
> Attachments: ZOOKEEPER-1910.patch, ZOOKEEPER-1910.patch,
> ZOOKEEPER-1910.patch
>
>
> Consider a case where zkclient has added 2 data watchers(say 'w1' and 'w2')
> on '/node1'.
> Now user has removed w1, but this is deleting the 'CnxnWatcher' in ZK server
> against the "/node1" path. This will affect other data watchers(if any) of
> same client on same path. In our case 'w2' would not be notified.
> Note: please see the attached test case to understand more.
--
This message was sent by Atlassian JIRA
(v6.2#6252)