Skip to content

State machine sub-regions do not resume from last state after restore from persistence #811

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

Open
razmanolescu opened this issue Sep 29, 2019 · 9 comments

Comments

@razmanolescu
Copy link

Problem statement

Issues

  • Using default configuration (with persistence provided by JpaRepositoryStateMachinePersist), all sub-regions seem to be reset upon restarting the SM. It continues from the fork parent task and re-runs all children.
  • It seems that if one of the sub-regions is in end-state and one is not (and persisted as such), the finalization (reaching end-state) of the latter will not trigger transition to join state and SM is stuck.

Expectations

  • The expectation is that all sub-regions current states are persisted by default. Once a SM is acquired from persistence source, it should initialize all sub-state current states correctly and begin transitioning
  • If one or more forked regions are saved with end-state, restarting parent SM should not inhibit transitioning to join-state, if remaining regions reach end-state.

Observations

It appears that the current state of each sub-region is persisted using the parent context (except in the case of initial state). This in turn overwrites the last sub-statemachine state, instead of being additive.
This works on explicit persistence of entire SM, so it may be that there might be an issue with context building.

Please see repo with example here

Please let me know if any additional details or setup support is required.

@razmanolescu
Copy link
Author

Bump

@jvalkeal, do you know if there is a known workaround for this?

@simbuatgit
Copy link

@jvalkeal Could u update on this issue. I am facing the same issue in implementing SM .

@jvalkeal
Copy link
Contributor

@simbuatgit are you also using persistence to db/jpa? I've been looking this and there might be an issue with persistent context as most of a persist/restore tests are using in-memory structure(to make tests faster and be outside of an external structure).

@jvalkeal
Copy link
Contributor

Think I finally found a probable reason for this issue. That runtime persister component with regions creates different entries(one for every region aka root, and childs in substate) in a DB while restore then how it's done expects contexts to be in one one entry. I'm going to see this a bit further.

@jmruvalcabav
Copy link

@jvalkeal do you have a workaround for this?, thanks!

@ShvetsovDV
Copy link

ShvetsovDV commented Jul 22, 2021

@jvalkeal
I think, for reason this problem, we need to fix two bags in AbstractPersistingStateMachineInterceptor:
1. definition of real "childRefs" for orthogonal states
Here we need to look at the line 171. I'am think condition "stateMachine.getState().isOrthogonal()" is unnecessary.
2. definition of real identifier of state machine for context
The fact is that all changes are saved for the main state machine(with a main state machine id). We need to fix it.

You can see my solution at ShvetsovDV@4837d83

And second part of fix it is edit resetStateMachine in AbstractStateMachine like this ShvetsovDV@e813399

@wonderslug
Copy link

Wondering what the state of this is? Im encountering this now and it would be nice to get a fix in.

@ShvetsovDV
Copy link

ShvetsovDV commented Apr 6, 2022 via email

@jenyayel
Copy link

@jvalkeal did you have a chance to look into this? I don't mind helping with the issue, but I would happy to some guidelines, especially if you made some progress on it.

P.S. I went over related issues and looked to the proposed fix by @ShvetsovDV

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

No branches or pull requests

7 participants