Skip to content

Commit b083a70

Browse files
Disable eager start by default (#1879)
1 parent 3670bce commit b083a70

File tree

2 files changed

+27
-10
lines changed

2 files changed

+27
-10
lines changed

temporal-sdk/src/main/java/io/temporal/client/WorkflowOptions.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public static final class Builder {
105105

106106
private List<ContextPropagator> contextPropagators;
107107

108-
private boolean disableEagerExecution;
108+
private boolean disableEagerExecution = true;
109109

110110
private Builder() {}
111111

@@ -331,6 +331,11 @@ public Builder setContextPropagators(@Nullable List<ContextPropagator> contextPr
331331
* could be dispatched on this local worker with the response to the start call if Server
332332
* supports it. This option can be used to disable this mechanism.
333333
*
334+
* <p>Default is true
335+
*
336+
* <p>WARNING: Eager start does not respect worker versioning. An eagerly started workflow may
337+
* run on any available local worker even if that worker is not in the default build ID set.
338+
*
334339
* @param disableEagerExecution if true, an eager local execution of the workflow task will
335340
* never be requested even if it is possible.
336341
*/

temporal-sdk/src/test/java/io/temporal/workflow/EagerWorkflowTaskDispatchTest.java

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,21 @@ public void workflowIsEagerlyDispatchedOnTheWorkerRegisteredWithTheCorrespondent
9898
.getWorkflowClient()
9999
.newWorkflowStub(
100100
TestWorkflows.NoArgsWorkflow.class,
101-
WorkflowOptions.newBuilder().setTaskQueue(testWorkflowRule.getTaskQueue()).build());
101+
WorkflowOptions.newBuilder()
102+
.setTaskQueue(testWorkflowRule.getTaskQueue())
103+
.setDisableEagerExecution(false)
104+
.build());
102105
workflowStub1.execute();
103106
assertTrue(START_CALL_INTERCEPTOR.wasLastStartEager);
104107
TestWorkflows.NoArgsWorkflow workflowStub2 =
105108
workerFactory2
106109
.getWorkflowClient()
107110
.newWorkflowStub(
108111
TestWorkflows.NoArgsWorkflow.class,
109-
WorkflowOptions.newBuilder().setTaskQueue(testWorkflowRule.getTaskQueue()).build());
112+
WorkflowOptions.newBuilder()
113+
.setTaskQueue(testWorkflowRule.getTaskQueue())
114+
.setDisableEagerExecution(false)
115+
.build());
110116
workflowStub2.execute();
111117
assertTrue(START_CALL_INTERCEPTOR.wasLastStartEager);
112118

@@ -151,7 +157,10 @@ public void testNoEagerWorkflowTaskIfWorkerHasNoWorkflowsRegistered() {
151157
.getWorkflowClient()
152158
.newWorkflowStub(
153159
TestWorkflows.NoArgsWorkflow.class,
154-
WorkflowOptions.newBuilder().setTaskQueue(testWorkflowRule.getTaskQueue()).build());
160+
WorkflowOptions.newBuilder()
161+
.setTaskQueue(testWorkflowRule.getTaskQueue())
162+
.setDisableEagerExecution(false)
163+
.build());
155164
workflowStub.execute();
156165
assertFalse(
157166
"Eager dispatch shouldn't be requested for activity-only worker",
@@ -181,7 +190,10 @@ public void testNoEagerWorkflowTaskIfWorkerIsNotStarted() {
181190
.getWorkflowClient()
182191
.newWorkflowStub(
183192
TestWorkflows.NoArgsWorkflow.class,
184-
WorkflowOptions.newBuilder().setTaskQueue(testWorkflowRule.getTaskQueue()).build());
193+
WorkflowOptions.newBuilder()
194+
.setTaskQueue(testWorkflowRule.getTaskQueue())
195+
.setDisableEagerExecution(false)
196+
.build());
185197
workflowStub.execute();
186198
assertFalse(
187199
"Eager dispatch shouldn't be requested for a not started worker",
@@ -212,7 +224,10 @@ public void testNoEagerWorkflowTaskIfWorkerIsSuspended() {
212224
.getWorkflowClient()
213225
.newWorkflowStub(
214226
TestWorkflows.NoArgsWorkflow.class,
215-
WorkflowOptions.newBuilder().setTaskQueue(testWorkflowRule.getTaskQueue()).build());
227+
WorkflowOptions.newBuilder()
228+
.setTaskQueue(testWorkflowRule.getTaskQueue())
229+
.setDisableEagerExecution(false)
230+
.build());
216231
workflowStub.execute();
217232
assertFalse(
218233
"Eager dispatch shouldn't be requested for a suspended worker",
@@ -233,10 +248,7 @@ public void testNoEagerWFTIfDisabledOnWorkflowOptions() {
233248
.getWorkflowClient()
234249
.newWorkflowStub(
235250
TestWorkflows.NoArgsWorkflow.class,
236-
WorkflowOptions.newBuilder()
237-
.setTaskQueue(testWorkflowRule.getTaskQueue())
238-
.setDisableEagerExecution(true)
239-
.build());
251+
WorkflowOptions.newBuilder().setTaskQueue(testWorkflowRule.getTaskQueue()).build());
240252
workflowStub.execute();
241253
assertFalse(START_CALL_INTERCEPTOR.wasLastStartEager);
242254

0 commit comments

Comments
 (0)