Skip to content

Commit

Permalink
bugfix: non global domain workflow, when started, should not generate…
Browse files Browse the repository at this point in the history
… replication task (#862)
  • Loading branch information
wxing1292 authored Jun 19, 2018
1 parent 922b0e6 commit 9f78eca
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
15 changes: 5 additions & 10 deletions service/history/historyEngine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
1 change: 1 addition & 0 deletions service/history/historyReplicator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions service/history/mutableStateBuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 9f78eca

Please sign in to comment.