Skip to content

Commit 8c1d824

Browse files
authored
Do not add start WFT before processing commands (#7829)
## What changed? In an edge case in versioning we wanted to make sure that a new wft is generated after processing the previous wft completed event. The new wft was added in `afterAddWorkflowTaskCompletedEvent` which is run before processing commands. Now moved it to the api handler which is anyways taking care of similar cases to create new wft task after completion of the previous one. ## Why? The old logic could cause issues because it adds the new wft before the events generated from commands. ## How did you test it? - [ ] built - [ ] run locally and tested manually - [ ] covered by existing tests - [ ] added new unit test(s) - [ ] added new functional test(s) ## Potential risks None
1 parent 72cd2fd commit 8c1d824

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

service/history/api/respondworkflowtaskcompleted/api.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,10 @@ func (handler *WorkflowTaskCompletedHandler) Invoke(
481481
if request.GetForceCreateNewWorkflowTask() || // Heartbeat WT is always of Normal type.
482482
wtFailedShouldCreateNewTask ||
483483
hasBufferedEventsOrMessages ||
484-
activityNotStartedCancelled {
484+
activityNotStartedCancelled ||
485+
// If the workflow has an ongoing transition to another deployment version, we should ensure
486+
// it has a pending wft so it does not remain in the transition phase for long.
487+
ms.GetDeploymentTransition() != nil {
485488

486489
newWorkflowTaskType = enumsspb.WORKFLOW_TASK_TYPE_NORMAL
487490

service/history/workflow/workflow_task_state_machine.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,16 +1136,6 @@ func (m *workflowTaskStateMachine) afterAddWorkflowTaskCompletedEvent(
11361136
}
11371137
}
11381138

1139-
if transition != nil {
1140-
// There is still a transition going on. We need to schedule a new WFT so it goes to the
1141-
// transition deployment this time.
1142-
if _, err := m.ms.AddWorkflowTaskScheduledEvent(
1143-
false,
1144-
enumsspb.WORKFLOW_TASK_TYPE_NORMAL,
1145-
); err != nil {
1146-
return err
1147-
}
1148-
}
11491139
// Deployment and behavior before applying the data came from the completed wft.
11501140
wfDeploymentBefore := m.ms.GetEffectiveDeployment()
11511141
wfBehaviorBefore := m.ms.GetEffectiveVersioningBehavior()

0 commit comments

Comments
 (0)