File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -979,7 +979,11 @@ ProcessEvents:
979979 }
980980 }
981981 isReplay := len (reorderedEvents ) > 0 && reorderedHistory .IsReplayEvent (reorderedEvents [len (reorderedEvents )- 1 ])
982- if isReplay {
982+ // incomplete decisions (e.g. start without a complete) at the end of history will still have decisions in decisionsHelper
983+ // but there won't be corresponding respond events. This breaks the non-determinism check therefore we ignore such final partial decisions.
984+ // Example scenario is covered by TestReplayWorkflowHistory_Partial_NoDecisionEvents
985+ lastDecisionEventsForReplayTest := isReplayTest && ! reorderedHistory .HasNextDecisionEvents ()
986+ if isReplay && ! lastDecisionEventsForReplayTest {
983987 eventDecisions := eventHandler .decisionsHelper .getDecisions (true )
984988 if len (eventDecisions ) > 0 && ! skipReplayCheck {
985989 replayDecisions = append (replayDecisions , eventDecisions ... )
Original file line number Diff line number Diff line change @@ -99,6 +99,23 @@ func (s *workflowReplayerSuite) TestReplayWorkflowHistory_Partial_WithDecisionEv
9999 s .NoError (err )
100100}
101101
102+ // This test case covers partial decision scenario where a decision is started but not closed
103+ // History:
104+ //
105+ // 1: WorkflowExecutionStarted
106+ // 2: DecisionTaskScheduled
107+ // 3: DecisionTaskStarted
108+ // 4: DecisionTaskFailed
109+ // 5: DecisionTaskScheduled
110+ // 6: DecisionTaskStarted
111+ //
112+ // Notes on task handling logic during replay:
113+ //
114+ // reorderedHistory.NextDecisionEvents() ignores events 2, 3, 4 because it failed.
115+ // it only returns 1 and 6 to be replayed.
116+ // 6 changes the state in decisionsHelper (generates a decision) however there's no corresponding
117+ // respond due to missing close event (failed/complete etc.)
118+ // Such partial decisions at the end of the history is ignored during replay tests to avoid non-determinism error
102119func (s * workflowReplayerSuite ) TestReplayWorkflowHistory_Partial_NoDecisionEvents () {
103120 err := s .replayer .ReplayWorkflowHistory (s .logger , getTestReplayWorkflowPartialHistoryNoDecisionEvents (s .T ()))
104121 s .NoError (err )
You can’t perform that action at this time.
0 commit comments