pkuwm commented on a change in pull request #642: Fix handleNewSession creating 
ephemeral node with expired session
URL: https://github.com/apache/helix/pull/642#discussion_r363009316
 
 

 ##########
 File path: 
helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixManager.java
 ##########
 @@ -697,10 +706,16 @@ void createClient() throws Exception {
     int retryCount = 0;
     while (retryCount < 3) {
       try {
-        // TODO: synchronize this block and wait for the new non-zero session 
ID updated.
-        _zkclient.waitUntilConnected(_connectionInitTimeout, 
TimeUnit.MILLISECONDS);
-        handleStateChanged(KeeperState.SyncConnected);
-        handleNewSession();
+        // TODO: might be better to create a new method to return session id 
in waitUntilConnected.
+        synchronized (this) {
+          if (!_zkclient.waitUntilConnected(_connectionInitTimeout, 
TimeUnit.MILLISECONDS)) {
+            throw new ZkTimeoutException(
+                "Unable to connect to zookeeper server within timeout: " + 
_connectionInitTimeout
+                    + " ms.");
+          }
+          handleStateChanged(KeeperState.SyncConnected);
+          
handleNewSession(_zkclient.getHexSessionId(_zkclient.getSessionId()));
+        }
 
 Review comment:
   InstanceType.ADMINISTRATOR uses shared zkclient, but 
zkHelixManager.handleNewSession() will not do anything for 
InstanceType.ADMINISTRATOR. We should be fine with InstanceType.ADMINISTRATOR.
   I've made a note for cleaning up the retry part in createClient(). We will 
see if we can improve this to make it consistent with event thread running 
handleNewSession().

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