jiajunwang 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_r364004887
##########
File path:
helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixManager.java
##########
@@ -1134,9 +1159,31 @@ public void handleNewSession(final String sessionId)
throws Exception {
// Wait until we get a non-zero session id. Otherwise, getSessionId()
might be null.
waitUntilConnected();
- // TODO: filter out stale sessions here.
+ /*
+ * Filter out stale sessions. If a session id is not null and not the same
as current session
+ * id, this session is expired. With this filtering, expired sessions are
NOT handled,
+ * so performance is expected to improve.
+ */
+ if (sessionId != null && !getSessionId().equals(sessionId)) {
+ LOG.info("Session is expired and not handled. Expected: {}. Actual:
{}.", sessionId,
+ getSessionId());
+ return;
+ }
+
+ /*
+ * When a null session id is passed in, we will take current session's id
for following
+ * operations. Please note that current session might not be the one we
expect to handle,
+ * because the one we expect might be already expired when the zk event is
waiting in the
+ * event queue. Why we use current session here is for backward
compatibility with the old
+ * method handleNewSession().
+ */
+ if (sessionId == null) {
+ sessionId = getSessionId();
+ LOG.warn("Session id: <null> is passed in. Current session id: {} will
be used.", sessionId);
Review comment:
nit, LOG.debug?
----------------------------------------------------------------
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]