Skip to content

HDDS-15578. Prevent throwing InvalidStateTransitionException from updateContainerStateWithSequenceId#10525

Open
ivandika3 wants to merge 5 commits into
apache:masterfrom
ivandika3:HDDS-15578
Open

HDDS-15578. Prevent throwing InvalidStateTransitionException from updateContainerStateWithSequenceId#10525
ivandika3 wants to merge 5 commits into
apache:masterfrom
ivandika3:HDDS-15578

Conversation

@ivandika3

@ivandika3 ivandika3 commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

There are methods annotated with @Replicate that 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:

  • Leader submits FINALIZE for OPEN.
  • Before/apply ordering or duplicate report causes the current state to already be CLOSING.
  • Applying FINALIZE at CLOSING is invalid.
  • Exception escapes from replicated apply path.

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. Additionally, the makeStateTransitionIdempotent also adds a guard to make sure that transition is idempotent.

We can try to fix it by

  • Inside the replicated implementation, catch InvalidStateTransitionException.
  • Log and return without mutation.
  • Treat it as a stale/duplicate lifecycle event, not a fatal replicated-state-machine error.

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)

@ivandika3 ivandika3 self-assigned this Jun 18, 2026
@ivandika3 ivandika3 marked this pull request as ready for review June 18, 2026 05:20
@adoroszlai adoroszlai requested a review from ashishkumar50 June 18, 2026 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant