Repository navigation
Add eager start support for standalone activities #12349
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
Changes from all commits
bb4ae6c
7e83905
b02e5d6
76f9b8c
d9e4ced
a4e52c3
7bb39d1
d69cb31
b7bd052
ef78df7
bb028b0
969beae
aa3ef43
dbc41ea
1bab344
8af210a
e75545e
ec8317d
8b891d3
0242b8f
1f944bf
3ca4494
296e0a0
7e193e3
e1eddc1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -11,11 +11,13 @@ import ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "go.temporal.io/server/api/historyservice/v1" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "go.temporal.io/server/chasm" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "go.temporal.io/server/chasm/lib/activity/gen/activitypb/v1" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "go.temporal.io/server/common" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "go.temporal.io/server/common/contextutil" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "go.temporal.io/server/common/log" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "go.temporal.io/server/common/metrics" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "go.temporal.io/server/common/namespace" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| commonnexus "go.temporal.io/server/common/nexus" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "go.temporal.io/server/common/resource" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -38,6 +40,7 @@ type handler struct { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| linkValidator *linkValidator | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| logger log.Logger | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metricsHandler metrics.Handler | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| matchingClient resource.MatchingClient | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| namespaceRegistry namespace.Registry | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -47,6 +50,7 @@ func newHandler( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| linkValidator *linkValidator, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metricsHandler metrics.Handler, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| logger log.Logger, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| matchingClient resource.MatchingClient, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| namespaceRegistry namespace.Registry, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) *handler { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return &handler{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -55,6 +59,7 @@ func newHandler( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| linkValidator: linkValidator, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| logger: logger, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metricsHandler: metricsHandler, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| matchingClient: matchingClient, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| namespaceRegistry: namespaceRegistry, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -64,18 +69,22 @@ func newHandler( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // matching being delivered to a worker poll request. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func (h *handler) StartActivityExecution(ctx context.Context, req *activitypb.StartActivityExecutionRequest) (*activitypb.StartActivityExecutionResponse, error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| frontendReq := req.GetFrontendRequest() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var eagerTaskData *eagerActivityTaskData | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| reusePolicy, ok := businessIDReusePolicyMap[frontendReq.GetIdReusePolicy()] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if !ok { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return nil, serviceerror.NewInvalidArgumentf("unsupported ID reuse policy: %v", frontendReq.GetIdReusePolicy()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| conflictPolicy, ok := businessIDConflictPolicyMap[frontendReq.GetIdConflictPolicy()] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if !ok { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return nil, serviceerror.NewInvalidArgumentf("unsupported ID conflict policy: %v", frontendReq.GetIdConflictPolicy()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| reusePolicy, conflictPolicy, err := businessIDPolicies(frontendReq) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return nil, err | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| maxCallbacks := h.config.MaxCallbacksPerExecution(frontendReq.GetNamespace()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // TODO: Reconcile the Matching grant when the subsequent start does not create an eager task. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if frontendReq.GetRequestEagerExecution() && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| h.config.EnableActivityEagerDispatchCheck(frontendReq.GetNamespace()) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| !h.grantEagerActivityDispatch(ctx, req.GetNamespaceId(), frontendReq) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Matching grants are best-effort. On a denial or any Matching failure, schedule the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // activity normally instead of failing the start request. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| frontendReq.RequestEagerExecution = false | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| result, err := chasm.StartExecution( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ctx, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -84,27 +93,11 @@ func (h *handler) StartActivityExecution(ctx context.Context, req *activitypb.St | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| BusinessID: frontendReq.GetActivityId(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func(mutableContext chasm.MutableContext, request *workflowservice.StartActivityExecutionRequest) (*Activity, error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| newActivity, err := NewStandaloneActivity(mutableContext, request) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return nil, err | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if cbs := request.GetCompletionCallbacks(); len(cbs) > 0 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if err := newActivity.addCompletionCallbacks(mutableContext, request.GetRequestId(), cbs, maxCallbacks); err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return nil, err | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if len(request.GetLinks()) > 0 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if err := newActivity.attachLinks(mutableContext, request.GetLinks(), request.GetRequestId(), h.linkValidator, frontendReq.GetNamespace()); err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return nil, err | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| err = TransitionScheduled.Apply(newActivity, mutableContext, nil) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| newActivity, newEagerTaskData, err := h.newActivityForStartExecution(mutableContext, request, req.GetNamespaceId(), maxCallbacks) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return nil, err | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| eagerTaskData = newEagerTaskData | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return newActivity, nil | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| frontendReq, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -114,9 +107,12 @@ func (h *handler) StartActivityExecution(ctx context.Context, req *activitypb.St | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if alreadyStartedErr, ok := errors.AsType[*chasm.ExecutionAlreadyStartedError](err); ok { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return nil, serviceerror.NewActivityExecutionAlreadyStarted("activity execution already started", alreadyStartedErr.CurrentRequestID, alreadyStartedErr.CurrentRunID) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return nil, serviceerror.NewActivityExecutionAlreadyStarted( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "activity execution already started", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| alreadyStartedErr.CurrentRequestID, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| alreadyStartedErr.CurrentRunID, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return nil, err | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -130,6 +126,15 @@ func (h *handler) StartActivityExecution(ctx context.Context, req *activitypb.St | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var eagerTask *workflowservice.PollActivityTaskQueueResponse | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if result.Created && eagerTaskData != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| eagerTask, err = eagerTaskData.response(result.ExecutionRef) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return nil, err | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metrics.ActivityEagerExecutionCounter.With(eagerActivityMetricsHandler(h.metricsHandler, h.config, frontendReq)).Record(1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Apply on_conflict_options to an existing activity. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // TODO: Use chasm.UpdateWithStartExecution to avoid a second transaction once the engine supports BusinessIDConflictPolicyFail in the updateFn path. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cbs := frontendReq.GetCompletionCallbacks() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -176,8 +181,9 @@ func (h *handler) StartActivityExecution(ctx context.Context, req *activitypb.St | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return &activitypb.StartActivityExecutionResponse{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| FrontendResponse: &workflowservice.StartActivityExecutionResponse{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| RunId: result.ExecutionKey.RunID, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Started: result.Created, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| RunId: result.ExecutionKey.RunID, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Started: result.Created, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| EagerActivityTask: eagerTask, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Link: &commonpb.Link{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Variant: &commonpb.Link_Activity_{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Activity: &commonpb.Link_Activity{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -187,11 +193,87 @@ func (h *handler) StartActivityExecution(ctx context.Context, req *activitypb.St | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // EagerTask: TODO when supported, need to call the same code that would handle the HandleStarted API | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, nil | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| func (h *handler) newActivityForStartExecution( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
wenlong-gu marked this conversation as resolved.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mutableContext chasm.MutableContext, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| request *workflowservice.StartActivityExecutionRequest, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| namespaceID string, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| maxCallbacks int, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) (*Activity, *eagerActivityTaskData, error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| newActivity, err := NewStandaloneActivity(mutableContext, request) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return nil, nil, err | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if cbs := request.GetCompletionCallbacks(); len(cbs) > 0 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if err := newActivity.addCompletionCallbacks(mutableContext, request.GetRequestId(), cbs, maxCallbacks); err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return nil, nil, err | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if len(request.GetLinks()) > 0 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if err := newActivity.attachLinks(mutableContext, request.GetLinks(), request.GetRequestId(), h.linkValidator, request.GetNamespace()); err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return nil, nil, err | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if request.GetRequestEagerExecution() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| err = TransitionEagerStarted.Apply(newActivity, mutableContext, eagerStartEvent{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| requestID: request.GetRequestId(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| identity: request.GetIdentity(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| err = TransitionScheduled.Apply(newActivity, mutableContext, nil) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return nil, nil, err | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if !request.GetRequestEagerExecution() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return newActivity, nil, nil | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| eagerTaskData, err := newActivity.eagerActivityTaskData(mutableContext, eagerActivityTaskRequest{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| namespaceID: namespaceID, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| namespace: request.GetNamespace(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| requestID: request.GetRequestId(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return nil, nil, err | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return newActivity, eagerTaskData, nil | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+222
to
+245
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit — The eager branch checks
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if request.GetRequestEagerExecution() { | |
| err = TransitionEagerStarted.Apply(newActivity, mutableContext, eagerStartEvent{ | |
| requestID: request.GetRequestId(), | |
| identity: request.GetIdentity(), | |
| }) | |
| } else { | |
| err = TransitionScheduled.Apply(newActivity, mutableContext, nil) | |
| } | |
| if err != nil { | |
| return nil, nil, err | |
| } | |
| if !request.GetRequestEagerExecution() { | |
| return newActivity, nil, nil | |
| } | |
| eagerTaskData, err := newActivity.eagerActivityTaskData(mutableContext, eagerActivityTaskRequest{ | |
| namespaceID: namespaceID, | |
| namespace: request.GetNamespace(), | |
| requestID: request.GetRequestId(), | |
| }) | |
| if err != nil { | |
| return nil, nil, err | |
| } | |
| return newActivity, eagerTaskData, nil | |
| if !request.GetRequestEagerExecution() { | |
| return newActivity, nil, TransitionScheduled.Apply(newActivity, mutableContext, nil) | |
| } | |
| if err := TransitionEagerStarted.Apply(newActivity, mutableContext, eagerStartEvent{ | |
| requestID: request.GetRequestId(), | |
| identity: request.GetIdentity(), | |
| }); err != nil { | |
| return nil, nil, err | |
| } | |
| return newActivity, newActivity.eagerActivityTaskData(mutableContext, namespaceID, request.GetNamespace()), 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.
small — SAA eager start ignores
system.enableActivityEagerExecution, which still turns off eager activities for workflows.The WFA path only allows eager dispatch when
handler.config.EnableActivityEagerExecution(namespace)is true (workflow_task_completed_handler.go:544). The SAA path checks only the newactivity.enableEagerStarthere, andEnableActivityEagerDispatchCheckin history. An operator who setssystem.enableActivityEagerExecution=falseto stop all eager activity dispatch for a namespace still gets eager SAA tasks. They also have to know about a second key. The parity test sets both keys, so it does not catch this.Suggestion: Require both keys, or document that
activity.enableEagerStartis the only SAA switch. To require both, addEnableActivityEagerExecutionto the activityConfigand check it here: