Repository navigation
WHN impl 2: store worker control queue when workflow task starts - #12992
feiyang3cat wants to merge 2 commits into
Conversation
f0d570c to
9785e58
Compare
9785e58 to
6b58851
Compare
6b58851 to
cb28997
Compare
64d0457 to
9b8183f
Compare
9b8183f to
f7612e9
Compare
f7612e9 to
59205ae
Compare
59205ae to
2dae008
Compare
2dae008 to
e6ff69f
Compare
891953d to
8d45750
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Inline follow-up workflow tasks lose the worker control queue, leaving them without a heartbeat-notification destination.
1 open issue
3 files not reviewed
api/persistence/v1/executions.pb.go: Generated fileclient/matching/client_gen.go: Generated fileservice/history/interfaces/mutable_state_mock.go: Generated file
What changed in this PR
This PR records the control queue of workers that support workflow heartbeat notifications, providing a routing destination for the current workflow task.
Changes:
- Preserve worker capabilities through matching poll forwarding.
- Store control queues for normal and eager starts, with mutable-state lifecycle and replication support.
- Add unit coverage and update the Temporal API dependency.
| File | Description |
|---|---|
| service/matching/pri_forwarder.go | Forward workflow-task capabilities. |
| service/matching/matching_engine.go | Capture capabilities in poll metadata. |
| service/matching/forwarder_test.go | Verify worker metadata survives forwarding. |
| service/history/workflow/workflow_task_state_machine.go | Store, retrieve, and clear the control queue. |
| service/history/workflow/mutable_state_impl.go | Expose queue assignment and support replication. |
| service/history/workflow/mutable_state_impl_test.go | Cover queue lifecycle, speculative state, and replication. |
| service/history/workflow_heartbeat_notification_worker_control_queue_test.go | Test normal and eager-start queue persistence. |
| service/history/interfaces/workflow_task_info.go | Add the task’s worker control queue. |
| service/history/interfaces/mutable_state.go | Declare the queue setter. |
| service/history/interfaces/mutable_state_mock.go | Add the generated setter mock. |
| service/history/api/recordworkflowtaskstarted/api.go | Record the queue for capable polling workers. |
| service/history/api/create_workflow_util.go | Record the queue for capable eager-start workers. |
| proto/internal/temporal/server/api/persistence/v1/executions.proto | Define the persisted control-queue field. |
| go.sum | Add API dependency checksums. |
| go.mod | Update the Temporal API dependency. |
| client/matching/client_gen.go | Preserve capabilities in matching requests. |
| api/persistence/v1/executions.pb.go | Generate persistence bindings for the new field. |
Review effort: Balanced
| if req.PollRequest.GetCapabilities().GetSupportsWorkflowHeartbeatNotification() { | ||
| mutableState.SetWorkflowTaskWorkerControlQueue(req.PollRequest.GetWorkerControlTaskQueue()) | ||
| } |
There was a problem hiding this comment.
▎ Good catch, fixed. Both inline-start paths in RespondWorkflowTaskCompleted (normal and speculative) now carry over currentWorkflowTask.WorkerControlQueue to the new task. That's safe for two reasons:
▎ - The inline task always goes back to the caller, which must hold the token of the currently started task, so the caller is the worker that registered the queue.
▎ - The stored queue was only set when that worker reported SupportsWorkflowHeartbeatNotification.
▎
▎ I didn't use RespondWorkflowTaskCompletedRequest.WorkerControlTaskQueue, because that request's capabilities have no WHN flag. The speculative path only sets it in memory, so it doesn't add a persistence write.
▎
▎ Added TestInlineWorkflowTaskKeepsWorkerControlQueue. It covers normal and speculative inline tasks, each with and without a queue.
There was a problem hiding this comment.
@Copilot did you check my changes?
9f6d49b to
8573d52
Compare
8573d52 to
56016b5
Compare
| } | ||
|
|
||
| func (ms *MutableStateImpl) SetWorkflowTaskWorkerControlQueue(queue string) { | ||
| ms.workflowTaskManager.SetWorkflowTaskWorkerControlQueue(queue) |
There was a problem hiding this comment.
only sets in the memory, and if set by speculative workflow task, it won't change all in-mem behavior
56016b5 to
4db0d27
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The lifecycle subtests use fatal assertions bound to the parent test, so a failure can abort remaining cases instead of being reported against the individual subtest.
2 open issues
3 files not reviewed
api/persistence/v1/executions.pb.go: Generated fileclient/matching/client_gen.go: Generated fileservice/history/interfaces/mutable_state_mock.go: Generated file
Review effort: Balanced
4db0d27 to
2a48b97
Compare
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the worker control-queue propagation and persistence changes.
1 open issue
1 resolved since last review
3 files not reviewed
api/persistence/v1/executions.pb.go: Generated fileclient/matching/client_gen.go: Generated fileservice/history/interfaces/mutable_state_mock.go: Generated file
Review effort: Balanced
2a48b97 to
fee10ef
Compare
When the worker that starts a workflow task supports workflow heartbeat notifications, store its worker control task queue in ExecutionInfo as workflow_task_worker_control_queue. It comes from PollWorkflowTaskQueue, or from StartWorkflowExecution for an eager workflow task, and is cleared with the other workflow task fields. Matching now keeps poll capabilities when forwarding a workflow task poll.
fee10ef to
4937998
Compare
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the worker control-queue changes.
1 open issue
3 files not reviewed
api/persistence/v1/executions.pb.go: Generated fileclient/matching/client_gen.go: Generated fileservice/history/interfaces/mutable_state_mock.go: Generated file
Review effort: Balanced


What changed?
Why?
How did you test it?