[
https://issues.apache.org/jira/browse/ZOOKEEPER-442?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13870522#comment-13870522
]
Rakesh R commented on ZOOKEEPER-442:
------------------------------------
Awsome test.
I think I found one leak, where the map is growing even after the watcher
removal, like <"/0000000000/e-0000000000-0000000000", []> with empty watcher
list.
In the test case, exists call is keep on adding pre-watchers to the newly
formed non-existed path as shown below:
/0000000000/e-0000000000-0000000000
/0000000000/e-0000000000-0000000001
/0000000000/e-0000000000-0000000002
/0000000000/e-0000000000-0000000003
/0000000000/e-0000000000-0000000004
/0000000000/e-0000000000-0000000005
private final Map<String, Set<Watcher>> existWatches = new HashMap<String,
Set<Watcher>>();
When I observe the 'existWatches' datastructure, on every zk.exists call, it is
adding one entry like:
{/0000000000/e-0000000000-0000000000=[org.apache.zookeeper.ExerciseRemoveWatchTest$IgnoringWatcher@10e4fd7]}
While removing I had missed one condition where I removed the watcher and but
leaving an entry in the map with empty watcher list. This is growing and is
causing the trouble.
{/0000000000/e-0000000000-0000000000=[]}
{/0000000000/e-0000000000-0000000001=[]}
{/0000000000/e-0000000000-0000000002=[]}
{code}
I have to do the map cleanup when 'watchers.size() <= 0' in
ZKWatchManager#removeWatches
Set<Watcher> watchers = pathVsWatcher.get(path);
if (watchers != null) {
if (watchers.remove(watcher)) {
// found path watcher
removedWatchers.add(watcher);
// cleanup <path vs watchlist>
if (watchers.size() <= 0) {
pathVsWatcher.remove(path);
}
success = true;
}
}
{code}
> need a way to remove watches that are no longer of interest
> -----------------------------------------------------------
>
> Key: ZOOKEEPER-442
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-442
> Project: ZooKeeper
> Issue Type: Sub-task
> Components: java client, server
> Reporter: Benjamin Reed
> Assignee: Rakesh R
> Priority: Critical
> Fix For: 3.5.0
>
> Attachments: Remove Watch API.pdf, ZOOKEEPER-442.patch,
> ZOOKEEPER-442.patch, ZOOKEEPER-442.patch, ZOOKEEPER-442.patch,
> ZOOKEEPER-442.patch, ZOOKEEPER-442.patch, ZOOKEEPER-442.patch,
> ZOOKEEPER-442.patch, ZOOKEEPER-442.patch, ZOOKEEPER-442.patch,
> ZOOKEEPER-442.patch, ZOOKEEPER-442.patch
>
>
> currently the only way a watch cleared is to trigger it. we need a way to
> enumerate the outstanding watch objects, find watch events the objects are
> watching for, and remove interests in an event.
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)