keith-turner commented on code in PR #5040:
URL: https://github.com/apache/accumulo/pull/5040#discussion_r1834570097


##########
core/src/main/java/org/apache/accumulo/core/fate/zookeeper/ZooCache.java:
##########
@@ -294,41 +296,46 @@ public List<String> getChildren(final String zPath) {
       @Override
       public List<String> run() throws KeeperException, InterruptedException {
 
-        // only read volatile once for consistency
-        ImmutableCacheCopies lic = immutableCache;
-        var cachedChildren = lic.childrenCache.get(zPath);
-        // null is cached as a value, that is the reason for the secondary 
containsKey check
-        if (cachedChildren != null || lic.childrenCache.containsKey(zPath)) {
-          return cachedChildren;
+        var zcNode = nodeCache.get(zPath);
+        if (zcNode != null && zcNode.childrenSet) {
+          return zcNode.children;
         }
 
-        cacheWriteLock.lock();
         try {
-          List<String> children = childrenCache.get(zPath);
-          // null is cached as a value, that is the reason for the secondary 
containsKey check
-          if (children != null || lic.childrenCache.containsKey(zPath)) {
-            return children;
-          }
-
-          final ZooKeeper zooKeeper = getZooKeeper();
+          zcNode = nodeCache.compute(zPath, (zp, zcn) -> {
+            // recheck the children now that lock is held on key
+            if (zcn != null && zcn.childrenSet) {
+              return zcn;
+            }
 
-          children = zooKeeper.getChildren(zPath, watcher);
-          if (children != null) {
-            children = List.copyOf(children);
-          }
-          childrenCache.put(zPath, children);
-          immutableCache = new ImmutableCacheCopies(++updateCount, 
immutableCache, childrenCache);
-          return children;
-        } catch (KeeperException ke) {
-          if (ke.code() != Code.NONODE) {
-            throw ke;
+            try {
+              final ZooKeeper zooKeeper = getZooKeeper();
+              List<String> children = null;
+              // TODO zookeeper may never return null

Review Comment:
   These changes preserve the existing possibly incorrect behavior as I was not 
sure if it was incorrect or not.



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