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


##########
core/src/main/java/org/apache/accumulo/core/fate/zookeeper/ServiceLock.java:
##########
@@ -360,7 +407,9 @@ public void process(WatchedEvent event) {
                 // created a Watcher on a node that does not exist. Delete the 
watcher we just
                 // created.
                 zooKeeper.removeWatches(nodeToWatch, this, WatcherType.Any, 
true);
-                determineLockOwnership(createdEphemeralNode, lw);
+                if (createdNodeName != null) {
+                  determineLockOwnership(lw);
+                }

Review Comment:
   After checking createdNodeName and before calling determineLockOwnership() 
it could change to null.  Would be better to sync this entire block.  Also the 
check on createdNodeName could be moved before the exist check,  if 
createNodeName is null there is no need to do that check.
   
   Could change the code in the try block to the following.
   
   ```java
                 synchronized (ServiceLock.this){
                   if(createdNodeName != null) {
                     Stat restat = zooKeeper.exists(nodeToWatch, this);
                     if (restat == null) {
                       // if stat is null from the zookeeper.exists(path, 
Watcher) call, then we just
                       // created a Watcher on a node that does not exist. 
Delete the watcher we just
                       // created.
                       zooKeeper.removeWatches(nodeToWatch, this, 
WatcherType.Any, true);
                       determineLockOwnership(lw);
                     } else {
                       LOG.debug("[{}] Renewed watch on prior node  {}", 
vmLockPrefix, nodeToWatch);
                     }
                   }
                 }
   ```



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