lei-xia commented on a change in pull request #644: Customize IZkStateListener
to add handleNewSession(sessionId)
URL: https://github.com/apache/helix/pull/644#discussion_r354954437
##########
File path:
helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixManager.java
##########
@@ -1099,8 +1099,28 @@ public void handleStateChanged(KeeperState state) {
@Override
public void handleNewSession() throws Exception {
- LOG.info(
- "Handle new session, instance: " + _instanceName + ", type: " +
_instanceType);
+ handleNewSession(null);
+ }
+
+ @Override
+ public void handleNewSession(final String sessionId) throws Exception {
+ /*
+ * When Zk session is re-established, some old events from the previous
session might still be
+ * left in in the event queue. This may cause some issues related to
session expiration.
+ * Theoretically, an old event coming from an old session will be
re-triggered or reset in the
+ * new event, so we don't have to process the old event.
+ * Thus, if the session is expired, we will discard this session and will
NOT run following
+ * tasks for this session. If session id is null, it means this operation
is not session aware
+ * and so we don't have to check session expiration.
+ */
+ if (sessionId != null && !getSessionId().equals(sessionId)) {
+ LOG.info("Session: {} is not handled because it is expired.", sessionId);
Review comment:
Minor: also print out the current SessionId for debug purpose.
----------------------------------------------------------------
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]