Skip to content

Commit

Permalink
Fix replay for child workflow and release restriction for in-complete… (
Browse files Browse the repository at this point in the history
  • Loading branch information
longquanzheng authored Jun 15, 2019
1 parent aa63613 commit 47943da
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .gen/go/shared/idl.go

Large diffs are not rendered by default.

40 changes: 38 additions & 2 deletions .gen/go/shared/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion idl/github.com/uber/cadence/shared.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -464,8 +464,9 @@ struct WorkflowExecutionStartedEventAttributes {
56: optional string continuedFailureReason
57: optional binary continuedFailureDetails
58: optional binary lastCompletionResult
59: optional string originalExecutionRunId // This is the very first runID along the chain of ContinueAsNew and Reset.
59: optional string originalExecutionRunId // This is the runID when the WorkflowExecutionStarted event is written
60: optional string identity
61: optional string firstExecutionRunId // This is the very first runID along the chain of ContinueAsNew and Reset.
70: optional RetryPolicy retryPolicy
80: optional i32 attempt
90: optional i64 (js.type = "Long") expirationTimestamp
Expand Down
11 changes: 8 additions & 3 deletions internal/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,6 @@ func replayWorkflowHistory(logger *zap.Logger, service workflowserviceclient.Int
return errors.New("first event is not WorkflowExecutionStarted")
}
last := events[len(events)-1]
if last.GetEventType() != shared.EventTypeWorkflowExecutionCompleted && last.GetEventType() != shared.EventTypeWorkflowExecutionContinuedAsNew {
return errors.New("last event is not WorkflowExecutionCompleted or WorkflowExecutionContinuedAsNew")
}

attr := first.WorkflowExecutionStartedEventAttributes
if attr == nil {
Expand All @@ -341,6 +338,10 @@ func replayWorkflowHistory(logger *zap.Logger, service workflowserviceclient.Int
RunId: common.StringPtr(uuid.NewUUID().String()),
WorkflowId: common.StringPtr("ReplayId"),
}
if first.WorkflowExecutionStartedEventAttributes.GetOriginalExecutionRunId() != "" {
execution.RunId = common.StringPtr(first.WorkflowExecutionStartedEventAttributes.GetOriginalExecutionRunId())
}

task := &shared.PollForDecisionTaskResponse{
Attempt: common.Int64Ptr(0),
TaskToken: []byte("ReplayTaskToken"),
Expand Down Expand Up @@ -372,6 +373,10 @@ func replayWorkflowHistory(logger *zap.Logger, service workflowserviceclient.Int
if err != nil {
return err
}

if last.GetEventType() != shared.EventTypeWorkflowExecutionCompleted && last.GetEventType() != shared.EventTypeWorkflowExecutionContinuedAsNew {
return nil
}
err = fmt.Errorf("replay workflow doesn't return the same result as the last event, resp: %v, last: %v", resp, last)
if resp != nil {
completeReq, ok := resp.(*shared.RespondDecisionTaskCompletedRequest)
Expand Down

0 comments on commit 47943da

Please sign in to comment.