Skip to content

Reset may start submachine too early #386

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jvalkeal opened this issue Jun 30, 2017 · 1 comment
Closed

Reset may start submachine too early #386

jvalkeal opened this issue Jun 30, 2017 · 1 comment
Labels
type/bug Is a bug report
Milestone

Comments

@jvalkeal
Copy link
Contributor

jvalkeal commented Jun 30, 2017

Logic is a bit off when machines are reset and problem comes with nested states when threading is used.

09:05:31,025  INFO Test worker support.LifecycleObjectSupport [Test worker] - started org.springframework.statemachine.support.DefaultStateMachineExecutor@19b181ca
09:05:31,025  INFO Test worker support.LifecycleObjectSupport [Test worker] - started MANUAL AUTOMATIC  /  / uuid=d78a114e-d696-46cd-a0e3-cc2ee70442bb / id=null
09:05:31,025 DEBUG Test worker support.AbstractStateMachine [Test worker] - State reseted: stateMachine=[ERROR MANUAL AUTOMATIC TASKS TASK_2 TASK_2_INITIAL TASK_3_INITIAL TASK_3 TASK_1 TASK_1_INITIAL READY JOIN FORK CHOICE  / ERROR / uuid=c271d93c-a40c-45cc-8364-c4231387e21e / id=null] stateMachineContext=[DefaultStateMachineContext [id=null, childs=[], state=ERROR, historyStates={}, event=null, eventHeaders=null, extendedState=null]]
09:05:31,025 DEBUG ThreadPoolTaskExecutor-1 support.DefaultStateMachineExecutor [ThreadPoolTaskExecutor-1] - Process event queue, size=0
09:05:31,025  INFO Test worker support.LifecycleObjectSupport [Test worker] - started StateMachineState [getIds()=[ERROR], toString()=AbstractState [id=ERROR, pseudoState=null, deferred=[], entryActions=[], exitActions=[], stateActions=[], regions=[], submachine=MANUAL AUTOMATIC  /  / uuid=d78a114e-d696-46cd-a0e3-cc2ee70442bb / id=null], getClass()=class org.springframework.statemachine.state.StateMachineState]
09:05:31,025 DEBUG Test worker support.AbstractStateMachine [Test worker] - Request to reset state machine: stateMachine=[MANUAL AUTOMATIC  /  / uuid=d78a114e-d696-46cd-a0e3-cc2ee70442bb / id=null] stateMachineContext=[DefaultStateMachineContext [id=null, childs=[], state=ERROR, historyStates={}, event=null, eventHeaders=null, extendedState=null]]
09:05:31,026 DEBUG ThreadPoolTaskExecutor-1 support.AbstractStateMachine [ThreadPoolTaskExecutor-1] - Enter state=[ObjectState [getIds()=[AUTOMATIC], getClass()=class org.springframework.statemachine.state.ObjectState, hashCode()=1309168632, toString()=AbstractState [id=AUTOMATIC, pseudoState=org.springframework.statemachine.state.DefaultPseudoState@40cfb449, deferred=[], entryActions=[org.springframework.statemachine.recipes.tasks.TasksHandler$6@44f03888], exitActions=[], stateActions=[], regions=[], submachine=null]]]
09:05:31,026  INFO Test worker support.LifecycleObjectSupport [Test worker] - started ObjectState [getIds()=[AUTOMATIC], getClass()=class org.springframework.statemachine.state.ObjectState, hashCode()=1309168632, toString()=AbstractState [id=AUTOMATIC, pseudoState=org.springframework.statemachine.state.DefaultPseudoState@40cfb449, deferred=[], entryActions=[org.springframework.statemachine.recipes.tasks.TasksHandler$6@44f03888], exitActions=[], stateActions=[], regions=[], submachine=null]]
09:05:31,026 DEBUG Test worker support.AbstractStateMachine [Test worker] - Request to reset state machine: stateMachine=[TASK_2 TASK_2_INITIAL  /  / uuid=97c7524d-0ef9-4fc3-bc89-3e4d3665dd6f / id=null] stateMachineContext=[DefaultStateMachineContext [id=null, childs=[], state=ERROR, historyStates={}, event=null, eventHeaders=null, extendedState=null]]
09:05:31,026 DEBUG Test worker support.AbstractStateMachine [Test worker] - Request to reset state machine: stateMachine=[TASK_3_INITIAL TASK_3  /  / uuid=ab460d8a-6abb-4213-8a87-9414a9b47036 / id=null] stateMachineContext=[DefaultStateMachineContext [id=null, childs=[], state=ERROR, historyStates={}, event=null, eventHeaders=null, extendedState=null]]
09:05:31,026 DEBUG Test worker support.AbstractStateMachine [Test worker] - Request to reset state machine: stateMachine=[TASK_1 TASK_1_INITIAL  /  / uuid=745b41e4-1178-4745-a261-954865a6eab2 / id=null] stateMachineContext=[DefaultStateMachineContext [id=null, childs=[], state=ERROR, historyStates={}, event=null, eventHeaders=null, extendedState=null]]

Machines should not start until user request start from root machine.

There are further issues for restoring machines as this same issue causes some bad behaviour as persist/restore also tries to handle lifecycle logic during a restore operation.

@jvalkeal jvalkeal added the type/bug Is a bug report label Jun 30, 2017
@jvalkeal jvalkeal added this to the 1.2.6.RELEASE milestone Jul 8, 2017
jvalkeal added a commit to jvalkeal/spring-statemachine that referenced this issue Jul 8, 2017
- Fixing machine lifecycle logic when machine
  is restored which effectively should not touch
  any lifecycle methods as start/stop is
  user level action.
- Remove start/stop from restore and attempt to
  do same when root machine is started. This also
  needed some further changes as some functionality
  for restore was essentially broken
- Fixes spring-projects#386
@jvalkeal
Copy link
Contributor Author

jvalkeal commented Jul 8, 2017

Merged per 8c18dc8

@jvalkeal jvalkeal closed this as completed Jul 8, 2017
jvalkeal added a commit that referenced this issue Jul 9, 2017
- Fixing machine lifecycle logic when machine
  is restored which effectively should not touch
  any lifecycle methods as start/stop is
  user level action.
- Remove start/stop from restore and attempt to
  do same when root machine is started. This also
  needed some further changes as some functionality
  for restore was essentially broken
- Backport #386
- Relates #307
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Is a bug report
Projects
None yet
Development

No branches or pull requests

1 participant