temporal icon indicating copy to clipboard operation
temporal copied to clipboard

Prevent workflow task and activity task generation when workflow is paused

Open gow opened this issue 1 month ago • 2 comments

What changed?

  • Prevents workflow task generation when paused (ex: signals, activity completions, child workflow completions etc)
  • Prevents activity task generation when a workflow is paused and an inflight workflow task comes back with start activity commands.
  • Prevents eager activity starts when the workflow is paused.

Why?

When a workflow is paused, we should not generate any more new activity and workflow tasks.

How did you test it?

  • [x] built
  • [ ] run locally and tested manually
  • [x] covered by existing tests
  • [ ] added new unit test(s)
  • [x] added new functional test(s)

[!NOTE] Prevents new workflow/activity tasks and updates on paused workflows (disables eager activities, rejects force-create WFT), and avoids WFT scheduling across signal, reapply, and close-transaction paths with comprehensive tests.

  • Behavior changes (paused workflows):
    • Block new workflow tasks when paused:
      • Reject ForceCreateNewWorkflowTask in respondworkflowtaskcompleted (api.go).
      • Skip WFT scheduling in signalwithstartworkflow and NDC events_reapplier.
      • Guard ScheduleWorkflowTask and closeTransactionHandleWorkflowTaskScheduling against paused state.
      • UpdateWorkflowWithNew no longer schedules WFT if paused.
    • Block activity dispatch when paused:
      • In workflow_task_completed_handler.go, disable eager activity and bypass activity task generation when paused.
  • API/Interfaces:
    • Add MutableState.IsWorkflowExecutionStatusPaused() and implement in workflow/mutable_state_impl.go.
  • Tests:
    • New/updated unit and functional tests covering paused behavior for updates, signals, reapply, WFT completion, activity failure, and transfer queue (tests/pause_workflow_execution_test.go, various api_*_test.go, events_reapplier_test.go, transfer_queue_active_task_executor_test.go).

Written by Cursor Bugbot for commit 10512802ec80e7cc989a484ffda7dc6310655e00. This will update automatically on new commits. Configure here.

gow avatar Nov 24 '25 06:11 gow

This needs more work. Moving it back to draft.

gow avatar Dec 05 '25 00:12 gow

I think task_refresher needs to be updated as well to not regenerated activity & workflow task. and yeah I think I'd prefer the logic lives in refresher not task generator, and keeps generator logic simple/straightforward.

Looked into this and it seems like existing checks will already prevent task generation. In both places we first check if the wokflow status is in RUNNING before generating the tasks.

gow avatar Dec 09 '25 18:12 gow