Repository navigation
Conversation
A notification that lands while a task runs was carried by a task the transaction close scheduled, so matching dispatched it and its start was a second write. The completion handler now creates that task the way it does for a buffered Signal and returns it when the worker asks for the next task.
A subscription's cursor left behind while the task ran had the same gap as a pending notification: the transaction close scheduled the task and matching started it. The slices the handed task carries are now decided before the commit, since staging a range on the cursor is a write of the completion's transaction.
Owner
Author
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 PR hands a Workflow Task scheduled by a channel notification back with the completion response.
What changed?
RespondWorkflowTaskCompletedcreates the next Workflow Task when the run holds a pending channel notification, either kind, next to the buffered-events case, so the scheduled event that carries the notification and the task's start land in the completion's write.return_new_workflow_taskset, the worker eligible, sticky as today. Without the request the task goes through matching as before.MutableState.HasPendingChannelNotificationsis the read the handler asks, resolved through the same read-only view the transaction close uses forHasPendingStreamData.HasPendingStreamData. The slices the handed task carries are decided before the commit, since staging a range on the cursor is a write of the completion's transaction.tests/inline_handoff_test.gocovers both channel kinds, a native stream, the no-request path and a subscribe command handed the channel's latest.Part of AI-198 (epic AI-37).
Why?
The linked channel measurement put the listener at about 120 state transitions against the Signal's 103 for the same 41 tasks. The difference was the task start: a Signal's task is handed to the completing worker in the completion response, so scheduled and started are one write, while a task scheduled from a pending notification went through matching and its start was a write of its own. With this change the channel pays what a Signal pays on the listener side.
How did you test it?
go build ./..., golangci-lint and theerrortypevet are clean on the touched packages. Unit tests ran for./service/history/api/respondworkflowtaskcompleted/...,./service/history/workflow/...,./chasm/lib/channel/...and./chasm/lib/workflow/.... The functional tests ran with-tags disable_grpc_modules,test_dep: for a subscribed channel and for a linked one, a notify during a running task comes back with the completion response as a started task whose scheduled event carries it, for one state transition rather than two, a completion without the request leaves the task to matching, a repeat of what the handed task carries waits as pending and schedules its own task, and a subscribe command on a channel that already holds a notification gets the latest on the handed task. For a native stream, an append during a running task comes back the same way with the slice on the handed task, and the no-request path still goes through matching. The existing notification channel, linked channel and native stream suites pass.