diff --git a/service/history/historyEngine.go b/service/history/historyEngine.go index 4545cde5445..436df0f29e5 100644 --- a/service/history/historyEngine.go +++ b/service/history/historyEngine.go @@ -313,14 +313,11 @@ func (e *historyEngineImpl) StartWorkflowExecution(startRequest *h.StartWorkflow return nil, err } msBuilder.GetExecutionInfo().LastFirstEventID = startedEvent.GetEventId() - if msBuilder.GetReplicationState() != nil { - msBuilder.UpdateReplicationStateLastEventID("", msBuilder.GetCurrentVersion(), msBuilder.GetNextEventID()-1) - } - - createReplicationTask := e.shard.GetService().GetClusterMetadata().IsGlobalDomainEnabled() + createReplicationTask := msBuilder.GetReplicationState() != nil var replicationState *persistence.ReplicationState var replicationTasks []persistence.Task if createReplicationTask { + msBuilder.UpdateReplicationStateLastEventID("", msBuilder.GetCurrentVersion(), msBuilder.GetNextEventID()-1) replicationState = msBuilder.GetReplicationState() replicationTask := &persistence.HistoryReplicationTask{ FirstEventID: common.FirstEventID, @@ -1955,14 +1952,11 @@ func (e *historyEngineImpl) SignalWithStartWorkflowExecution(ctx context.Context return nil, err } msBuilder.GetExecutionInfo().LastFirstEventID = startedEvent.GetEventId() - if msBuilder.GetReplicationState() != nil { - msBuilder.UpdateReplicationStateLastEventID("", msBuilder.GetCurrentVersion(), msBuilder.GetNextEventID()-1) - } - - createReplicationTask := e.shard.GetService().GetClusterMetadata().IsGlobalDomainEnabled() + createReplicationTask := msBuilder.GetReplicationState() != nil var replicationState *persistence.ReplicationState var replicationTasks []persistence.Task if createReplicationTask { + msBuilder.UpdateReplicationStateLastEventID("", msBuilder.GetCurrentVersion(), msBuilder.GetNextEventID()-1) replicationState = msBuilder.GetReplicationState() replicationTask := &persistence.HistoryReplicationTask{ FirstEventID: common.FirstEventID, @@ -1988,6 +1982,7 @@ func (e *historyEngineImpl) SignalWithStartWorkflowExecution(ctx context.Context NextEventID: msBuilder.GetNextEventID(), LastProcessedEvent: common.EmptyEventID, TransferTasks: transferTasks, + ReplicationTasks: replicationTasks, DecisionVersion: decisionVersion, DecisionScheduleID: decisionScheduleID, DecisionStartedID: decisionStartID, diff --git a/service/history/historyReplicator.go b/service/history/historyReplicator.go index 1e4e243687e..9cc02225bf3 100644 --- a/service/history/historyReplicator.go +++ b/service/history/historyReplicator.go @@ -496,6 +496,7 @@ func (r *historyReplicator) replicateWorkflowStarted(context *workflowExecutionC createWorkflow := func(isBrandNew bool, prevRunID string) error { _, err = r.shard.CreateWorkflowExecution(&persistence.CreateWorkflowExecutionRequest{ + // NOTE: should not set the replication task, since we are in the standby RequestID: executionInfo.CreateRequestID, DomainID: domainID, Execution: execution, diff --git a/service/history/mutableStateBuilder.go b/service/history/mutableStateBuilder.go index 28809a46ac9..7eb15b0085c 100644 --- a/service/history/mutableStateBuilder.go +++ b/service/history/mutableStateBuilder.go @@ -2330,6 +2330,8 @@ func (e *mutableStateBuilder) ReplicateWorkflowExecutionContinuedAsNewEvent(sour setTaskVersion(newStateBuilder.GetCurrentVersion(), newTransferTasks, nil) e.continueAsNew = &persistence.CreateWorkflowExecutionRequest{ + // NOTE: there is no replication task for the start / decision scheduled event, + // the above 2 events will be replicated along with previous continue as new event. RequestID: uuid.New(), DomainID: domainID, Execution: newExecution,