Store worker attributes needed by server to propagate nexus tasks to worker#9231
Merged
Store worker attributes needed by server to propagate nexus tasks to worker#9231
Conversation
This was referenced Feb 5, 2026
yycptt
reviewed
Feb 7, 2026
service/history/api/respondworkflowtaskcompleted/workflow_task_completed_handler.go
Outdated
Show resolved
Hide resolved
f1e1ee5 to
e795849
Compare
43ace13 to
2ecbdfd
Compare
yycptt
approved these changes
Feb 12, 2026
Member
yycptt
left a comment
There was a problem hiding this comment.
LGTM overall. Please land after removing the unnecessary field.
proto/internal/temporal/server/api/persistence/v1/executions.proto
Outdated
Show resolved
Hide resolved
04db6f1 to
b72cf9f
Compare
Add workerControlTaskQueue parameter to AddActivityTaskStartedEvent and persist it in ActivityInfo when an activity starts. This enables routing activity cancellation requests to the correct worker's control queue via Nexus. Changes: - Add worker_control_task_queue field to ActivityInfo proto - Update MutableState interface and implementation - Pass workerControlTaskQueue from poll request for regular activities - Pass from RespondWorkflowTaskCompleted request for eager activities - Update all test call sites
…ontrol_task_queue fields
b72cf9f to
e319a6c
Compare
e319a6c to
5390759
Compare
rkannan82
added a commit
to temporalio/api
that referenced
this pull request
Apr 6, 2026
…711) <!-- Describe what has changed in this PR --> **What changed?** Added worker_control_task_queue to poll requests: - PollActivityTaskQueueRequest - PollWorkflowTaskQueueRequest Note: worker_instance_key was already added to these requests in #686. Added worker_instance_key and worker_control_task_queue to: - RespondWorkflowTaskCompletedRequest: This API is used to eagerly fetch activity. <!-- Tell your future self why have you made these changes --> **Why?** To enable server to send control tasks to worker. Each worker provides a worker_control_task_queue (a dedicated per-worker Nexus task queue) so the server can send control tasks directly to it. Example flow: - User cancels a workflow. - Server sends activity cancellation tasks to all workers that could be processing activities belonging to that workflow. - Worker will receive the cancellation message even when activity heartbeat is not enabled. <!-- Are there any breaking changes on binary or code level? --> Breaking changes: None [Server PR](temporalio/temporal#9231) --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
temporal-cicd bot
pushed a commit
to temporalio/api-go
that referenced
this pull request
Apr 6, 2026
…(#711) <!-- Describe what has changed in this PR --> **What changed?** Added worker_control_task_queue to poll requests: - PollActivityTaskQueueRequest - PollWorkflowTaskQueueRequest Note: worker_instance_key was already added to these requests in #686. Added worker_instance_key and worker_control_task_queue to: - RespondWorkflowTaskCompletedRequest: This API is used to eagerly fetch activity. <!-- Tell your future self why have you made these changes --> **Why?** To enable server to send control tasks to worker. Each worker provides a worker_control_task_queue (a dedicated per-worker Nexus task queue) so the server can send control tasks directly to it. Example flow: - User cancels a workflow. - Server sends activity cancellation tasks to all workers that could be processing activities belonging to that workflow. - Worker will receive the cancellation message even when activity heartbeat is not enabled. <!-- Are there any breaking changes on binary or code level? --> Breaking changes: None [Server PR](temporalio/temporal#9231) --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Resolves merge conflicts in executions.proto, mutable_state_impl_test.go, and go.sum. Updates api-go replace directive to 5423d0dd678a which includes the worker control task queue attributes from temporalio/api#711. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Match the comment style from temporalio/api#711. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
spkane31
pushed a commit
to temporalio/api
that referenced
this pull request
Apr 9, 2026
…711) <!-- Describe what has changed in this PR --> **What changed?** Added worker_control_task_queue to poll requests: - PollActivityTaskQueueRequest - PollWorkflowTaskQueueRequest Note: worker_instance_key was already added to these requests in #686. Added worker_instance_key and worker_control_task_queue to: - RespondWorkflowTaskCompletedRequest: This API is used to eagerly fetch activity. <!-- Tell your future self why have you made these changes --> **Why?** To enable server to send control tasks to worker. Each worker provides a worker_control_task_queue (a dedicated per-worker Nexus task queue) so the server can send control tasks directly to it. Example flow: - User cancels a workflow. - Server sends activity cancellation tasks to all workers that could be processing activities belonging to that workflow. - Worker will receive the cancellation message even when activity heartbeat is not enabled. <!-- Are there any breaking changes on binary or code level? --> Breaking changes: None [Server PR](temporalio/temporal#9231) --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
…l/persist-worker-key # Conflicts: # go.sum
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Main already has the direct dependency at the same version. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
carlydf
approved these changes
Apr 11, 2026
rkannan82
added a commit
that referenced
this pull request
Apr 11, 2026
…Nexus (#9232) ## What changed? New outbound task type (`WorkerCommandsTask`) that carries worker commands to be dispatched to workers via Nexus. Uses the generic `WorkerCommand` proto (not cancel-activity-specific), so this task type can carry any future command types. Suggested review order: proto changes → `worker_commands_task.go` → `task_generator.go` → `workflow_task_completed_handler.go` Key pieces: - **Proto**: `TASK_TYPE_WORKER_COMMANDS` enum, `WorkerCommandsTask` in `OutboundTaskInfo` with `repeated WorkerCommand`. - **Task definition**: `worker_commands_task.go` — implements outbound `Task` and `HasDestination` interfaces. - **Task creation** (`workflow_task_completed_handler.go`, `task_generator.go`): When `RequestCancelActivityTask` is processed for a started activity whose worker has a control queue, collects a `CancelActivityCommand` with the activity's task token. Commands are batched by destination control queue and flushed as one `WorkerCommandsTask` per queue at the end of WFT processing. - **Serialization**: `task_serializers.go` for persistence round-tripping. Dispatch is a no-op here — handled in #9233. Gated by dynamic config `EnableCancelActivityWorkerCommand` (default: off). ## Why? To support proactive activity cancellation without waiting for heartbeat. This is the task creation leg of the flow. 1. [#9231] Store `worker_control_task_queue` in `ActivityInfo` at activity start. 2. **[This PR]** On `RequestCancelActivityTask`, batch commands by control queue into `WorkerCommandsTask` outbound tasks. 3. [#9233] Dispatch each task as a Nexus `ExecuteCommands` operation to the worker, with a 3-attempt retry cap. 4. [SDK] Worker receives the cancel command and cancels the running activity. Gated by dynamic config `EnableCancelActivityWorkerCommand` (default: off). ## How did you test it? **Unit tests** cover task generation, command batching (including multi-queue batching), task serialization round-tripping, and the feature-flag-off path. --------- Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
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.
What changed?
As part of RecordActivityTaskStarted flow, store worker_control_task_queue for an activity in the mutable state (ActivityInfo).
Main changes:
Why?
To support activity cancellation without activity heartbeat.
Overall flow:
How did you test it?