Skip to content

Commit 47943da

Browse files
Fix replay for child workflow and release restriction for in-complete… (#755)
1 parent aa63613 commit 47943da

File tree

4 files changed

+50
-8
lines changed

4 files changed

+50
-8
lines changed

.gen/go/shared/idl.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.gen/go/shared/types.go

Lines changed: 38 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

idl/github.com/uber/cadence/shared.thrift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,8 +464,9 @@ struct WorkflowExecutionStartedEventAttributes {
464464
56: optional string continuedFailureReason
465465
57: optional binary continuedFailureDetails
466466
58: optional binary lastCompletionResult
467-
59: optional string originalExecutionRunId // This is the very first runID along the chain of ContinueAsNew and Reset.
467+
59: optional string originalExecutionRunId // This is the runID when the WorkflowExecutionStarted event is written
468468
60: optional string identity
469+
61: optional string firstExecutionRunId // This is the very first runID along the chain of ContinueAsNew and Reset.
469470
70: optional RetryPolicy retryPolicy
470471
80: optional i32 attempt
471472
90: optional i64 (js.type = "Long") expirationTimestamp

internal/worker.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,9 +328,6 @@ func replayWorkflowHistory(logger *zap.Logger, service workflowserviceclient.Int
328328
return errors.New("first event is not WorkflowExecutionStarted")
329329
}
330330
last := events[len(events)-1]
331-
if last.GetEventType() != shared.EventTypeWorkflowExecutionCompleted && last.GetEventType() != shared.EventTypeWorkflowExecutionContinuedAsNew {
332-
return errors.New("last event is not WorkflowExecutionCompleted or WorkflowExecutionContinuedAsNew")
333-
}
334331

335332
attr := first.WorkflowExecutionStartedEventAttributes
336333
if attr == nil {
@@ -341,6 +338,10 @@ func replayWorkflowHistory(logger *zap.Logger, service workflowserviceclient.Int
341338
RunId: common.StringPtr(uuid.NewUUID().String()),
342339
WorkflowId: common.StringPtr("ReplayId"),
343340
}
341+
if first.WorkflowExecutionStartedEventAttributes.GetOriginalExecutionRunId() != "" {
342+
execution.RunId = common.StringPtr(first.WorkflowExecutionStartedEventAttributes.GetOriginalExecutionRunId())
343+
}
344+
344345
task := &shared.PollForDecisionTaskResponse{
345346
Attempt: common.Int64Ptr(0),
346347
TaskToken: []byte("ReplayTaskToken"),
@@ -372,6 +373,10 @@ func replayWorkflowHistory(logger *zap.Logger, service workflowserviceclient.Int
372373
if err != nil {
373374
return err
374375
}
376+
377+
if last.GetEventType() != shared.EventTypeWorkflowExecutionCompleted && last.GetEventType() != shared.EventTypeWorkflowExecutionContinuedAsNew {
378+
return nil
379+
}
375380
err = fmt.Errorf("replay workflow doesn't return the same result as the last event, resp: %v, last: %v", resp, last)
376381
if resp != nil {
377382
completeReq, ok := resp.(*shared.RespondDecisionTaskCompletedRequest)

0 commit comments

Comments
 (0)