jiajunwang commented on a change in pull request #1124:
URL: https://github.com/apache/helix/pull/1124#discussion_r456156072



##########
File path: 
helix-core/src/main/java/org/apache/helix/controller/stages/CurrentStateComputationStage.java
##########
@@ -77,15 +84,19 @@ public void process(ClusterEvent event) throws Exception {
       String instanceName = instance.getInstanceName();
       String instanceSessionId = instance.getEphemeralOwner();
 
-      // update pending messages
-      Map<String, Message> messages = cache.getMessages(instanceName);
-      Map<String, Message> relayMessages = 
cache.getRelayMessages(instanceName);
-      updatePendingMessages(instance, messages.values(), currentStateOutput, 
relayMessages.values(), resourceMap);
-
       // update current states.
       Map<String, CurrentState> currentStateMap = 
cache.getCurrentState(instanceName,
           instanceSessionId);
       updateCurrentStates(instance, currentStateMap.values(), 
currentStateOutput, resourceMap);
+
+      Map<String, Map<String, Message>> existingStaleMessages = 
cache.getStaleMessages();
+      currentStateOutput.setStaleMessageMap(existingStaleMessages);
+      // update pending messages
+      Map<String, Message> messages = cache.getMessages(instanceName);
+      Map<String, Message> relayMessages = 
cache.getRelayMessages(instanceName);
+      updatePendingMessages(instance, messages.values(), currentStateOutput,
+          relayMessages.values(), resourceMap, existingStaleMessages);
+      cache.setStaleMessages(currentStateOutput.getStaleMessageMap());

Review comment:
       I got the first point. Should be fine. Thanks for the explanation.
   
   Regarding the leadership switch, the new leader won't know your cached 
value. So it will treat the previous message ( "first M->S message") as not 
stale. In general, if you have any logic depends on the cache, then the 
leadership switch will be troublesome.




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