lei-xia commented on a change in pull request #1066:
URL: https://github.com/apache/helix/pull/1066#discussion_r460179649



##########
File path: 
helix-core/src/main/java/org/apache/helix/controller/stages/MessageDispatchStage.java
##########
@@ -78,7 +78,17 @@ protected void processEvent(ClusterEvent event, 
MessageOutput messageOutput) thr
         batchMessage(dataAccessor.keyBuilder(), messagesToSend, resourceMap, 
liveInstanceMap,
             manager.getProperties());
 
+    String expectedSession = 
event.getAttribute(AttributeName.EVENT_SESSION.name());
+    // An early check for expected leader session. If the sessions don't 
match, it means the
+    // controller lost leadership, then messages should not be sent and 
pipeline should stop.
+    // This avoids potential double masters for a single partition.
+    if (expectedSession != null && 
!expectedSession.equals(manager.getSessionId())) {
+      throw new StageException(
+          "Controller: " + manager.getInstanceName() + " lost leadership! 
Expected session: "
+              + expectedSession + ", actual: " + manager.getSessionId());
+    }

Review comment:
       Why checking in every stage is too much? Do you mean code wise is too 
much, actually you just need the same code, in different place, right?




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