dlmarion commented on code in PR #5256:
URL: https://github.com/apache/accumulo/pull/5256#discussion_r1915631503


##########
core/src/main/java/org/apache/accumulo/core/fate/zookeeper/ZooCache.java:
##########
@@ -120,7 +150,14 @@ public void process(WatchedEvent event) {
         case NodeDeleted:
         case ChildWatchRemoved:
         case DataWatchRemoved:
-          remove(event.getPath());
+          // This code use to call remove(path), but that was when a Watcher 
was set
+          // on each node. With the Watcher being set at a higher level we 
need to remove
+          // the parent of the affected node and all of its children from the 
cache
+          // so that the parent and children node can be re-cached. If we only 
remove the
+          // affected node, then the cached children in the parent could be 
incorrect.
+          int lastSlash = event.getPath().lastIndexOf('/');
+          String parent = lastSlash == 0 ? "/" : event.getPath().substring(0, 
lastSlash);
+          clear((path) -> path.startsWith(parent));

Review Comment:
   Only need to do recursive deletes on NodeCreated, NodeDeleted. Clear only 
the node on NodeDataChanged. We don't expect to be triggered on 
ChildWatchRemoved, DataWatchRemoved and NodeChildrenChanged.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to