Skip to content
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

Disable eager start by default #1879

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public static final class Builder {

private List<ContextPropagator> contextPropagators;

private boolean disableEagerExecution;
private boolean disableEagerExecution = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we were to do it over again, I suspect we'd prefer enableEagerExecution here and I suspect that's what it'll be in all other SDKs. Is it worth breaking compatibility to make it more clearly opt-in? If we are willing to change it, I wonder if enableEagerStart is a better name to match Go.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree if we were doing it from scratch I would change the name, but we aren't doing it from scratch and we need to keep in mind of compatibility guarantees so I wouldn't change the name since it's more trouble then it's worth

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I think at least for any other SDKs we implement this in, we can be more Go like and just let Java be the outlier


private Builder() {}

Expand Down Expand Up @@ -331,6 +331,11 @@ public Builder setContextPropagators(@Nullable List<ContextPropagator> contextPr
* could be dispatched on this local worker with the response to the start call if Server
* supports it. This option can be used to disable this mechanism.
*
* <p>Default is true
*
* <p>WARNING: Eager start does not respect worker versioning. An eagerly started workflow may
* run on any available local worker even if that worker is not in the default build ID set.
*
* @param disableEagerExecution if true, an eager local execution of the workflow task will
* never be requested even if it is possible.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,21 @@ public void workflowIsEagerlyDispatchedOnTheWorkerRegisteredWithTheCorrespondent
.getWorkflowClient()
.newWorkflowStub(
TestWorkflows.NoArgsWorkflow.class,
WorkflowOptions.newBuilder().setTaskQueue(testWorkflowRule.getTaskQueue()).build());
WorkflowOptions.newBuilder()
.setTaskQueue(testWorkflowRule.getTaskQueue())
.setDisableEagerExecution(false)
.build());
workflowStub1.execute();
assertTrue(START_CALL_INTERCEPTOR.wasLastStartEager);
TestWorkflows.NoArgsWorkflow workflowStub2 =
workerFactory2
.getWorkflowClient()
.newWorkflowStub(
TestWorkflows.NoArgsWorkflow.class,
WorkflowOptions.newBuilder().setTaskQueue(testWorkflowRule.getTaskQueue()).build());
WorkflowOptions.newBuilder()
.setTaskQueue(testWorkflowRule.getTaskQueue())
.setDisableEagerExecution(false)
.build());
workflowStub2.execute();
assertTrue(START_CALL_INTERCEPTOR.wasLastStartEager);

Expand Down Expand Up @@ -151,7 +157,10 @@ public void testNoEagerWorkflowTaskIfWorkerHasNoWorkflowsRegistered() {
.getWorkflowClient()
.newWorkflowStub(
TestWorkflows.NoArgsWorkflow.class,
WorkflowOptions.newBuilder().setTaskQueue(testWorkflowRule.getTaskQueue()).build());
WorkflowOptions.newBuilder()
.setTaskQueue(testWorkflowRule.getTaskQueue())
.setDisableEagerExecution(false)
.build());
workflowStub.execute();
assertFalse(
"Eager dispatch shouldn't be requested for activity-only worker",
Expand Down Expand Up @@ -181,7 +190,10 @@ public void testNoEagerWorkflowTaskIfWorkerIsNotStarted() {
.getWorkflowClient()
.newWorkflowStub(
TestWorkflows.NoArgsWorkflow.class,
WorkflowOptions.newBuilder().setTaskQueue(testWorkflowRule.getTaskQueue()).build());
WorkflowOptions.newBuilder()
.setTaskQueue(testWorkflowRule.getTaskQueue())
.setDisableEagerExecution(false)
.build());
workflowStub.execute();
assertFalse(
"Eager dispatch shouldn't be requested for a not started worker",
Expand Down Expand Up @@ -212,7 +224,10 @@ public void testNoEagerWorkflowTaskIfWorkerIsSuspended() {
.getWorkflowClient()
.newWorkflowStub(
TestWorkflows.NoArgsWorkflow.class,
WorkflowOptions.newBuilder().setTaskQueue(testWorkflowRule.getTaskQueue()).build());
WorkflowOptions.newBuilder()
.setTaskQueue(testWorkflowRule.getTaskQueue())
.setDisableEagerExecution(false)
.build());
workflowStub.execute();
assertFalse(
"Eager dispatch shouldn't be requested for a suspended worker",
Expand All @@ -233,10 +248,7 @@ public void testNoEagerWFTIfDisabledOnWorkflowOptions() {
.getWorkflowClient()
.newWorkflowStub(
TestWorkflows.NoArgsWorkflow.class,
WorkflowOptions.newBuilder()
.setTaskQueue(testWorkflowRule.getTaskQueue())
.setDisableEagerExecution(true)
.build());
WorkflowOptions.newBuilder().setTaskQueue(testWorkflowRule.getTaskQueue()).build());
workflowStub.execute();
assertFalse(START_CALL_INTERCEPTOR.wasLastStartEager);

Expand Down