Skip to content

Commit

Permalink
Fix workflow replay to ignore -fm suffix (#1014)
Browse files Browse the repository at this point in the history
When existing workflow is being replayed with old activity names
it can result in non-deterministic error if activity was scheduled
with older cadence client version.

Ignore the suffix the same way, as the rest part of name is ignored
by extracting only the `lastPartOfName`
  • Loading branch information
vytautas-karpavicius committed Jul 28, 2020
1 parent 65840cc commit cadef60
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions internal/internal_task_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -1227,6 +1227,7 @@ matchLoop:
}

func lastPartOfName(name string) string {
name = strings.TrimSuffix(name, "-fm")
lastDotIdx := strings.LastIndex(name, ".")
if lastDotIdx < 0 || lastDotIdx == len(name)-1 {
return name
Expand Down
26 changes: 26 additions & 0 deletions internal/internal_worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,32 @@ func (s *internalWorkerTestSuite) TestReplayWorkflowHistory() {
require.NoError(s.T(), err)
}

func (s *internalWorkerTestSuite) TestReplayWorkflowHistory_Incomplete() {
taskList := "taskList1"
testEvents := []*shared.HistoryEvent{
createTestEventWorkflowExecutionStarted(1, &shared.WorkflowExecutionStartedEventAttributes{
WorkflowType: &shared.WorkflowType{Name: common.StringPtr("go.uber.org/cadence/internal.testReplayWorkflow")},
TaskList: &shared.TaskList{Name: common.StringPtr(taskList)},
Input: testEncodeFunctionArgs(getDefaultDataConverter()),
}),
createTestEventDecisionTaskScheduled(2, &shared.DecisionTaskScheduledEventAttributes{}),
createTestEventDecisionTaskStarted(3),
createTestEventDecisionTaskCompleted(4, &shared.DecisionTaskCompletedEventAttributes{}),
createTestEventActivityTaskScheduled(5, &shared.ActivityTaskScheduledEventAttributes{
ActivityId: common.StringPtr("0"),
ActivityType: &shared.ActivityType{Name: common.StringPtr("testActivity-fm")},
TaskList: &shared.TaskList{Name: &taskList},
}),
}

history := &shared.History{Events: testEvents}
logger := getLogger()
replayer := NewWorkflowReplayer()
replayer.RegisterWorkflow(testReplayWorkflow)
err := replayer.ReplayWorkflowHistory(logger, history)
require.NoError(s.T(), err)
}

func (s *internalWorkerTestSuite) TestReplayWorkflowHistory_LocalActivity() {
taskList := "taskList1"
testEvents := []*shared.HistoryEvent{
Expand Down

0 comments on commit cadef60

Please sign in to comment.