Skip to content

Commit

Permalink
ContinueAsNew should track the workflow previous run for NDC enabled (c…
Browse files Browse the repository at this point in the history
…adence-workflow#2853)

* Workflow will be in NDC enabled after ContinueAsNew
  • Loading branch information
yux0 authored Nov 22, 2019
1 parent 4b079a0 commit 505a79e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions service/history/historyReplicator.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,11 @@ func (r *historyReplicator) ApplyEvents(
request.WorkflowExecution.GetRunId(), request, logger)
}

// Sanity check to make only 2DC mutable state here
if msBuilder.GetReplicationState() == nil {
return &workflow.InternalServiceError{Message: "The mutable state does not support 2DC."}
}

logger.WithTags(tag.CurrentVersion(msBuilder.GetReplicationState().LastWriteVersion))
msBuilder, err = r.ApplyOtherEventsVersionChecking(ctx, context, msBuilder, request, logger)
if err != nil || msBuilder == nil {
Expand Down
3 changes: 2 additions & 1 deletion service/history/mutableStateBuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -3249,7 +3249,8 @@ func (e *mutableStateBuilder) AddContinueAsNewEvent(
domainName := e.domainEntry.GetInfo().Name
domainID := e.domainEntry.GetInfo().ID
var newStateBuilder *mutableStateBuilder
if e.config.EnableNDC(domainName) {
// If a workflow is ndc enabled, the continue as new should be ndc enabled.
if e.config.EnableNDC(domainName) || e.GetVersionHistories() != nil {
newStateBuilder = newMutableStateBuilderWithVersionHistories(
e.shard,
e.shard.GetEventsCache(),
Expand Down
5 changes: 5 additions & 0 deletions service/history/nDCHistoryReplicator.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,11 @@ func (r *nDCHistoryReplicatorImpl) applyEvents(
mutableState, err := context.loadWorkflowExecution()
switch err.(type) {
case nil:
// Sanity check to make only 3DC mutable state here
if mutableState.GetVersionHistories() == nil {
return &shared.InternalServiceError{Message: "The mutable state does not support 3DC."}
}

doContinue, branchIndex, err := r.applyNonStartEventsPrepareBranch(ctx, context, mutableState, task)
if err != nil {
return err
Expand Down

0 comments on commit 505a79e

Please sign in to comment.