Replace PauseState flag with PAUSE_REQUESTED state machine state#10265
Open
dandavison wants to merge 8 commits into
Open
Replace PauseState flag with PAUSE_REQUESTED state machine state#10265dandavison wants to merge 8 commits into
dandavison wants to merge 8 commits into
Conversation
5 tasks
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Reviewed by Cursor Bugbot for commit 3b0b77a. Configure here.
e28990c to
3d8f7cf
Compare
055b7ed to
7efdd4a
Compare
Adds three sub-tests to TestPauseActivityExecution that exercise the PAUSE_REQUESTED + worker-does-not-yield interaction. Each was missing before; verified by reverting the corresponding fix and observing the specific test fail: - StartToCloseTimeoutWhilePauseRequested: Pause a STARTED activity; the worker stops responding; the StartToCloseTimeoutTask must still fire (validator must accept PAUSE_REQUESTED) and the retry must land in PAUSED. - HeartbeatTimeoutWhilePauseRequested: Same pattern for HeartbeatTimeoutTask. - UpdateOptionsPreservesTimeoutsWhilePauseRequested: Pause a STARTED activity, call UpdateActivityExecutionOptions with a shorter StartToCloseTimeout; the handler must re-emit a fresh timeout task for PAUSE_REQUESTED activities, not only STARTED/CANCEL_REQUESTED. Otherwise the stamp bump silently strips timeout enforcement from the running worker.
7efdd4a to
d1b56e3
Compare
spkane31
approved these changes
May 26, 2026
Comment on lines
+50
to
+54
| // An operator pause was received while the activity was STARTED. The worker is still executing | ||
| // under its existing task token. The worker will be notified via ActivityPaused=true on its next | ||
| // heartbeat response. When the worker yields (failure with retries remaining, or timeout with | ||
| // retries remaining), the activity will transition to PAUSED. | ||
| ACTIVITY_EXECUTION_STATUS_PAUSE_REQUESTED = 10; |
Contributor
There was a problem hiding this comment.
This isn't entirely true, when the worker yields because an activity reaches a terminal state (failed,completed) it won't transition to pause requested.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

This is a proposed change to #10106.
See https://github.com/temporalio/temporal/pull/10106/changes#r3238854955
Note
High Risk
Changes core activity execution, pause/unpause, retry, timeout, and task-token semantics; incorrect transitions could strand activities or break worker heartbeats.
Overview
Replaces the hybrid pause model (STARTED +
PauseStateflag, blocked dispatch on SCHEDULED) with an explicitACTIVITY_EXECUTION_STATUS_PAUSE_REQUESTEDstate in the CHASM activity state machine.Pause / unpause: SCHEDULED still goes to PAUSED; STARTED now transitions to PAUSE_REQUESTED via
TransitionPauseRequested(recordspause_state, no attempt stamp bump so worker tokens and timeout tasks stay valid). Unpause uses PAUSED → SCHEDULED or PAUSE_REQUESTED → STARTED (TransitionUnpausedToStarted).isPaused()keys off status, notPauseState != nil.Retries: When the worker yields with retries left while in PAUSE_REQUESTED,
tryRescheduleusesTransitionAttemptFailedToPausedinstead of rescheduling to SCHEDULED—activity lands in PAUSED with attempt incremented.API / tasks: Heartbeats set
ActivityPausedfrom PAUSE_REQUESTED status; run state mapping is status-only (no hybrid SCHEDULED+flag logic). Dispatch and schedule-to-start validators no longer block onPauseState; start-to-close and heartbeat timeout validators treat PAUSE_REQUESTED like STARTED/CANCEL_REQUESTED. Options updates re-emit attempt timeouts for PAUSE_REQUESTED.Reset / cancel: Reset handles PAUSE_REQUESTED (optional unpause when not
keep_paused); simplified PAUSED reset path. Cancel+unpause test expectations updated (pause not surfaced on heartbeat when cancel wins).Adds integration tests for start-to-close / heartbeat timeout and options update while PAUSE_REQUESTED.
Reviewed by Cursor Bugbot for commit b55a3b3. Bugbot is set up for automated code reviews on this repo. Configure here.