jiajunwang commented on a change in pull request #642: Fix zk session race 
condition before creating a live instance
URL: https://github.com/apache/helix/pull/642#discussion_r352955442
 
 

 ##########
 File path: 
helix-core/src/main/java/org/apache/helix/manager/zk/zookeeper/ZkClient.java
 ##########
 @@ -531,12 +558,29 @@ public String create(final String path, Object datat, 
final List<ACL> acl, final
     try {
       final byte[] data = datat == null ? null : serialize(datat, path);
       checkDataSizeLimit(data);
-      String actualPath = retryUntilConnected(new Callable<String>() {
-        @Override
-        public String call() throws Exception {
-          return getConnection().create(path, data, acl, mode);
-        }
-      });
+
+      /*
+       * We pass different implementation of callable.
+       * 1. If the session id is null, it means the operation is NOT session 
aware.
+       * In this case, we will create a regular callable to create an 
ephemeral node.
+       * 2. Otherwise, the operation is session aware. We will use a 
SessionAwareCallable to
+       * create an ephemeral node, which is guaranteed to be created in the 
expected session.
+       */
+      String actualPath;
+      if (sessionId == null) {
 
 Review comment:
   I think we should only do the session aware creating when the create mode is 
Ephemeral. You can argue that we checked based on if sessionId is null or not. 
But that is not as good as to judge based on the create mode. Considering if 
the caller is creating in ephemeral mode but does not pass a session id. Then 
the logic is not correct.
   This is debatable though. Please let me know what do you think.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to