Skip to content

Commit

Permalink
Disable eager start by default (temporalio#1879)
Browse files Browse the repository at this point in the history
  • Loading branch information
Quinn-With-Two-Ns authored Oct 5, 2023
1 parent 3670bce commit b083a70
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
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;

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

0 comments on commit b083a70

Please sign in to comment.