Generally it is hard to reproduce in live system, due to it caused by some race condition.
But I'm able to reproduce similar issue in unit test with very small workflows: (It is not too clean, but I had not better idea to reproduce the symptom)
mistral.tests.unit.engine.test_set_state.TestSetState: (slightly copy of previous test in same test class)
self._await( predicate=wait_for_subworkflow_start, delay=0.1, timeout=20, fail_message="Sub workflow not started in time."
)
with db_api.transaction(): sub_wf_ex = db_api.get_workflow_execution(wf_ex.id).task_executions[0].executions[0]
self.await_workflow_success(wf_ex.id)
# The state in db is SUCCESS, but wf_ex still contains outdated info. self.assertEqual(states.RUNNING, sub_wf_ex.state)
wf = workflows.Workflow(sub_wf_ex)
# Trying to change the status of succeed execution. There is no error,
# only warning message that state has been changed in db. wf.stop(states.CANCELLED)
with db_api.transaction():
wf_ex = db_api.get_workflow_execution(sub_wf_ex.id)
Generally it is hard to reproduce in live system, due to it caused by some race condition.
But I'm able to reproduce similar issue in unit test with very small workflows: (It is not too clean, but I had not better idea to reproduce the symptom)
mistral. tests.unit. engine. test_set_ state.TestSetSt ate: (slightly copy of previous test in same test class)
def test_cancel_ set_state( self):
workflow: wf2
wf1_text = """
version: '2.0'
wf1:
tasks:
task1:
"""
wf2_text = """
action: std.noop
wait-before: 5
version: '2.0'
wf2:
tasks:
task1:
"""
wf_ex = self.engine. start_workflow( 'wf1')
def wait_for_ subworkflow_ start() :
with db_api. transaction( ):
db_ api.get_ workflow_ execution( wf_ex.id) .task_execution s[0].executions [0]
return True
return False
try:
except Exception:
)
with db_api.
# The state in db is SUCCESS, but wf_ex still contains outdated info.
self.assertEqu al(states. RUNNING, sub_wf_ex.state)
wf = workflows. Workflow( sub_wf_ ex)
# Trying to change the status of succeed execution. There is no error,
wf.stop( states. CANCELLED)
# only warning message that state has been changed in db.
with db_api. transaction( ): get_workflow_ execution( sub_wf_ ex.id)
wf_ex = db_api.