kaisun2000 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_r362980349
##########
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:
Walked through the code offline together. Yes, pkuwm is right.
For dedicated ZKClient, the first synconnected state change would be ignored.
This is the current behavior. We may revisit this assertion in Horizontal
Scaling effort. Let us document this one in ZkClient constructor
managingZkConnection part.
----------------------------------------------------------------
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]