pkuwm commented on a change in pull request #1066:
URL: https://github.com/apache/helix/pull/1066#discussion_r460227080



##########
File path: 
helix-core/src/main/java/org/apache/helix/controller/GenericHelixController.java
##########
@@ -312,6 +312,17 @@ private void forceRebalance(HelixManager manager, 
ClusterEventType eventType) {
     changeContext.setType(NotificationContext.Type.CALLBACK);
     String uid = UUID.randomUUID().toString().substring(0, 8);
     ClusterEvent event = new ClusterEvent(_clusterName, eventType, uid);
+
+    Optional<String> leaderSession = manager.getSessionIdIfLead();
+    // If session is not present, this cluster manager is not leader for the 
cluster.
+    if (!leaderSession.isPresent()) {
+      logger.warn("Cluster manager {} is not leader for {}. Event {} is 
discarded.",
+          manager.getInstanceName(), manager.getClusterName(), event);
+      return;
+    }
+
+    // Pipeline should be run and Zk writes should be completed by the event 
session.
+    event.addAttribute(AttributeName.EVENT_SESSION.name(), 
leaderSession.get());

Review comment:
       > Then when we created the event, just add the current session to the 
event attributes, is that good enough? We will check whether current controller 
is a leader and whether session matches anyway in handleEvent?
   
   It is OK to check session when handleEvent, which could reduce the checks 
when pushing event. Downside is when we create the events, manager session has 
already expired. Then we still push stale events to the event queue.




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



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

Reply via email to