dasahcc commented on a change in pull request #1362:
URL: https://github.com/apache/helix/pull/1362#discussion_r489759062
##########
File path:
helix-core/src/main/java/org/apache/helix/messaging/handling/HelixStateTransitionHandler.java
##########
@@ -463,6 +442,36 @@ public void onError(Exception e, ErrorCode code, ErrorType
type) {
}
+ // Verify the fromState and current state of the stateModel.
+ private void validateStaleMessage (boolean isPreCheck) throws Exception {
+ String fromState = _message.getFromState();
+ String toState = _message.getToState();
+ String partitionName = _message.getPartitionName();
+
+ // state in _currentStateDelta uses current state from state model. It has
the
+ // most up-to-date. current state. In case currentState in stateModel is
null,
+ // partition is in initial state and we using it as current state.
+ // Defined in HelixStateMachineEngine.
+ String state = _currentStateDelta.getState(partitionName);
+
+ if (toState.equalsIgnoreCase(state)) {
+ // To state equals current state, we can just ignore the message
+ throw new HelixDuplicatedStateTransitionException(String
Review comment:
This is not duplicate state transition. Could be some STs are old in
pending queue just not match what target state we have now.
##########
File path:
helix-core/src/main/java/org/apache/helix/messaging/handling/HelixStateTransitionHandler.java
##########
@@ -463,6 +442,36 @@ public void onError(Exception e, ErrorCode code, ErrorType
type) {
}
+ // Verify the fromState and current state of the stateModel.
+ private void validateStaleMessage (boolean isPreCheck) throws Exception {
+ String fromState = _message.getFromState();
+ String toState = _message.getToState();
+ String partitionName = _message.getPartitionName();
+
+ // state in _currentStateDelta uses current state from state model. It has
the
+ // most up-to-date. current state. In case currentState in stateModel is
null,
+ // partition is in initial state and we using it as current state.
+ // Defined in HelixStateMachineEngine.
+ String state = _currentStateDelta.getState(partitionName);
+
+ if (toState.equalsIgnoreCase(state)) {
+ // To state equals current state, we can just ignore the message
+ throw new HelixDuplicatedStateTransitionException(String
+ .format("Partition %s current state is same as toState (%s->%s) from
message.",
+ partitionName, fromState, toState));
+ } else if (!isPreCheck && fromState != null && !fromState.equals("*") &&
!fromState
Review comment:
Why we need this precheck flag? Two checks in onMessage and HelixTask
execution validation logic should be same
----------------------------------------------------------------
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]