Skip to content

Commit 38427e6

Browse files
bring back lastDecisionEventsForReplayTest because it's needed for partial decisions
1 parent fcf7c77 commit 38427e6

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

internal/internal_task_handlers.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,11 @@ ProcessEvents:
965965
}
966966
}
967967
isReplay := len(reorderedEvents) > 0 && reorderedHistory.IsReplayEvent(reorderedEvents[len(reorderedEvents)-1])
968-
if isReplay {
968+
// incomplete decisions (e.g. start without a complete) at the end of history will still have decisions in decisionsHelper
969+
// but there won't be corresponding respond events. This breaks the non-determinism check therefore we ignore such final partial decisions.
970+
// Example scenario is covered by TestReplayWorkflowHistory_Partial_NoDecisionEvents
971+
lastDecisionEventsForReplayTest := isReplayTest && !reorderedHistory.HasNextDecisionEvents()
972+
if isReplay && !lastDecisionEventsForReplayTest {
969973
eventDecisions := eventHandler.decisionsHelper.getDecisions(true)
970974
if len(eventDecisions) > 0 && !skipReplayCheck {
971975
replayDecisions = append(replayDecisions, eventDecisions...)

internal/workflow_replayer_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff 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
102119
func (s *workflowReplayerSuite) TestReplayWorkflowHistory_Partial_NoDecisionEvents() {
103120
err := s.replayer.ReplayWorkflowHistory(s.logger, getTestReplayWorkflowPartialHistoryNoDecisionEvents(s.T()))
104121
s.NoError(err)

0 commit comments

Comments
 (0)