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 189c807 commit cc79ab3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions internal/internal_task_handlers.go
Expand Up @@ -1223,6 +1223,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
24 changes: 24 additions & 0 deletions internal/internal_worker_test.go
Expand Up @@ -219,6 +219,30 @@ 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(nil, testReplayWorkflow),
}),
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()
err := ReplayWorkflowHistory(logger, history)
require.NoError(s.T(), err)
}

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

0 comments on commit cc79ab3

Please sign in to comment.