-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Single workflow pause API #8605
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
5a861df to
5c592f0
Compare
c76e337 to
728fbd9
Compare
cmd/tools/genrpcwrappers/main.go
Outdated
| f, ok := t.FieldByName(fieldName) | ||
| if !ok { | ||
| fmt.Printf("\nstack trace: path: [%s]\n", path) | ||
| fmt.Println(string(debug.Stack())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| } | ||
|
|
||
| // VerifyChildExecutionCompletionRecorded checks if child completion result is recorded in parent workflow. | ||
| // This is only used by standby transfer close execution logic to make sure parent workflow has the result |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wonder if we can add a linter for these extra spaces at the end of lines, just muddles up your PR and they're hard to undo because it's likely a diff in editor settings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. I too agree this should be a lint rule. I'm not even sure which setting in my editor causes this on save.
| const ( | ||
| testEndSignal = "test-end" | ||
| pauseIdentity = "functional-test" | ||
| pauseReason = "pausing workflow for acceptance test" | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these are duplicated in the tests, could they be package level consts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a very large package. So adding a package level const is probably not a good idea. I'll initialize these in test setup so that they are done only once and scoped to this test.
| workflowFn := func(ctx workflow.Context) (string, error) { | ||
| signalCh := workflow.GetSignalChannel(ctx, testEndSignal) | ||
| var signalPayload string | ||
| signalCh.Receive(ctx, &signalPayload) | ||
| return signalPayload, nil | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
workflowFn is duplicated, could also break this out
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do.
| // TODO: currently pause workflow execution does not intercept workflow creation. Fix the reset of this test when that is implemented. | ||
| // For now sending this signal will complete the workflow and finish the test. | ||
| err = s.SdkClient().SignalWorkflow(ctx, workflowID, runID, testEndSignal, "test end signal") | ||
| s.NoError(err) | ||
|
|
||
| s.EventuallyWithT(func(t *assert.CollectT) { | ||
| desc, err := s.SdkClient().DescribeWorkflowExecution(ctx, workflowID, runID) | ||
| require.NoError(t, err) | ||
| info := desc.GetWorkflowExecutionInfo() | ||
| require.NotNil(t, info) | ||
| require.Equal(t, enumspb.WORKFLOW_EXECUTION_STATUS_COMPLETED, info.GetStatus()) | ||
| }, 5*time.Second, 200*time.Millisecond) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making sure I understand this correctly, we don't intercept the signal yet, but we're planning on adding that in a future PR before the first release?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. This workflow and the tests will change a bit in subsequent PRs.
common/dynamicconfig/constants.go
Outdated
| ) | ||
|
|
||
| WorkflowPauseEnabled = NewNamespaceBoolSetting( | ||
| "history.WorkflowPauseEnabled", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
frontend?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved it.
| } | ||
|
|
||
| // PauseWorkflowExecution pauses a workflow execution. | ||
| func (wh *WorkflowHandler) PauseWorkflowExecution(ctx context.Context, request *workflowservice.PauseWorkflowExecutionRequest) (_ *workflowservice.PauseWorkflowExecutionResponse, retError error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does pause workflow count as an action? if so we need to update the telemetry interceptor to emit an action metric with the api is called.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added it.
|
|
||
| // copy pause info to the response if it exists | ||
| if executionInfo.PauseInfo != nil { | ||
| result.WorkflowExecutionInfo.PauseInfo = &workflowpb.WorkflowExecutionPauseInfo{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WorkflowExecutionInfo is used by visibility as well. Shall we add PauseInfo to WorkflowExtendedInfo instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok. I'll add it to WorkflowExtendedInfo and then update this PR.
| return nil, serviceerror.NewInvalidArgument("pause request is nil.") | ||
| } | ||
|
|
||
| if !shard.GetConfig().WorkflowPauseEnabled(namespaceID.String()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should do this in frontend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
2155224 to
c002113
Compare
c002113 to
408fa90
Compare
| return nil, err | ||
| } | ||
| return response, nil | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Potential null pointer dereference in client shard routing
The PauseWorkflowExecution client method calls request.GetPauseRequest().GetWorkflowId() without first checking if GetPauseRequest() returns nil. If the pause_request field is nil, this will cause a nil pointer dereference. While the history service API layer checks for nil and returns an error, the client-side wrapper should be defensive, similar to how CompleteNexusOperationChasm handles potential nil values by deserializing and checking before accessing nested fields.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is in generated code.
408fa90 to
1d4e330
Compare
36c201e to
35acc0c
Compare
What changed?
Note: This API is part of an experimental feature - "pause single workflow"
Followup PRs:
Why?
This API is needed to implement the "pause single workflow" feature.
How did you test it?
Note
Adds a new PauseWorkflowExecution API (frontend + history) gated by per-namespace config and exposes pause info via DescribeWorkflowExecution, with client support and tests.
PauseWorkflowExecutionwith messagesPauseWorkflowExecutionRequest/Responseinrequest_response.protoand service definitions; generated Go, gRPC handlers, and mocks.pauseworkflow.InvokeandHandler.PauseWorkflowExecution(adds workflow paused event; no WFT creation).PauseWorkflowExecution.WorkflowHandler.PauseWorkflowExecutionforwarding to history; gated byWorkflowPauseEnabled.frontend.WorkflowPauseEnabled(namespace-scoped).WorkflowExecutionExtendedInfo.PauseInfowhen present.PauseWorkflowExecution.go.temporal.io/apiversion.Written by Cursor Bugbot for commit ed7ce3a. This will update automatically on new commits. Configure here.