HDDS-15578. Prevent throwing InvalidStateTransitionException from updateContainerStateWithSequenceId#10525
Conversation
ashishkumar50
left a comment
There was a problem hiding this comment.
@ivandika3 Thanks for the patch, LGTM. Need below one clarification.
| if (newState.getNumber() > oldState.getNumber()) { | ||
| ExecutionUtil.create(() -> { | ||
| containers.updateState(id, oldState, newState); | ||
| transactionBuffer.addToBuffer(containerStore, id, |
There was a problem hiding this comment.
Above containerInfo.updateSequenceId needs to move here?
There was a problem hiding this comment.
I don't think it's needed since we simply want to catch the InvalidStateTransitionException.
|
@ashishkumar50 Note that this is technically a no-op patch since the SCM transition container lifecycle uses |
szetszwo
left a comment
There was a problem hiding this comment.
@ivandika3 , thanks for working on this! Then change looks good. Just a minor comment inlined.
szetszwo
left a comment
There was a problem hiding this comment.
+1 the change looks good.
|
Thanks @ashishkumar50 @szetszwo for the reviews. |
What changes were proposed in this pull request?
There are methods annotated with
@Replicatethat can throw InvalidStateTransitionException like ContainerStateManager#updateContainerStateWithSequenceId.When the method is applied by SCM Ratis, an exception from the StateMachineUpdater path can terminate SCM although it is not really a critical error (e.g. if there are duplicate events, we can simply ignore one).
Example risk (Edit: Due to the makeStateTransitionIdempotent, this is not really valid):
The chance is very low since most of there is a check of the container state before in updateContainerStateWithSequenceId the caller will check that the current container state is expected, but it's there.
Note that the
makeStateTransitionIdempotentalso adds a guard to make sure that transition is idempotent.We can try to fix it by
Or we can simply catch InvalidStateTransitionException SCMStateMachine#applyTransaction, but this means that all future InvalidStateTransitionException are non-fatal.
What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-15578
How was this patch tested?
CI (https://github.com/ivandika3/ozone/actions/runs/27731733234)