Skip to content

Commit c293cae

Browse files
committed
Prevent eager activity start when paused
1 parent 25a4b89 commit c293cae

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

service/history/api/respondworkflowtaskcompleted/workflow_task_completed_handler.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -505,12 +505,19 @@ func (handler *workflowTaskCompletedHandler) handleCommandScheduleActivity(
505505
eagerStartActivity := attr.RequestEagerExecution && handler.config.EnableActivityEagerExecution(namespace) &&
506506
(!versioningUsed || attr.UseWorkflowBuildId)
507507

508-
// we bypass activity task generation if either eagerStartActivity is true or the workflow is paused.
509-
bypassTaskGeneration := eagerStartActivity || (handler.mutableState.GetExecutionState().Status == enumspb.WORKFLOW_EXECUTION_STATUS_PAUSED)
508+
// if the workflow is paused, we bypass activity task generation and also prevent eager activity execution.
509+
bypassActivityTaskGeneration := eagerStartActivity
510+
if handler.mutableState.GetExecutionState().Status == enumspb.WORKFLOW_EXECUTION_STATUS_PAUSED {
511+
bypassActivityTaskGeneration = true
512+
eagerStartActivity = false
513+
} else { // if not we bypass activity task generation if eager start activity is requested.
514+
bypassActivityTaskGeneration = eagerStartActivity
515+
}
516+
510517
event, _, err := handler.mutableState.AddActivityTaskScheduledEvent(
511518
handler.workflowTaskCompletedID,
512519
attr,
513-
bypassTaskGeneration,
520+
bypassActivityTaskGeneration,
514521
)
515522
if err != nil {
516523
return nil, nil, handler.failWorkflowTaskOnInvalidArgument(enumspb.WORKFLOW_TASK_FAILED_CAUSE_SCHEDULE_ACTIVITY_DUPLICATE_ID, err)

0 commit comments

Comments
 (0)