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

Don't schedule LA on completed workflow #1902

Closed
Closed
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
6 changes: 3 additions & 3 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ steps:
queue: "default"
docker: "*"
command: "./gradlew --no-daemon test -x checkLicenseMain -x checkLicenses -x spotlessCheck -x spotlessApply -x spotlessJava -P edgeDepsTest"
timeout_in_minutes: 15
timeout_in_minutes: 20
plugins:
- docker-compose#v3.8.0:
run: unit-test-test-service-edge
Expand All @@ -15,7 +15,7 @@ steps:
queue: "default"
docker: "*"
command: "./gradlew --no-daemon test -x checkLicenseMain -x checkLicenses -x spotlessCheck -x spotlessApply -x spotlessJava"
timeout_in_minutes: 15
timeout_in_minutes: 20
plugins:
- docker-compose#v3.8.0:
run: unit-test-docker-jdk8
Expand All @@ -26,7 +26,7 @@ steps:
queue: "default"
docker: "*"
command: "./gradlew --no-daemon checkLicenseMain checkLicenses spotlessCheck"
timeout_in_minutes: 15
timeout_in_minutes: 20
plugins:
- docker-compose#v3.8.0:
run: jdk11
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ public WorkflowTaskResult handleWorkflowTask(
}

handleWorkflowTaskImpl(workflowTask, historyIterator);
processLocalActivityRequests(wftHearbeatDeadline);
if (!context.isWorkflowMethodCompleted()) {
processLocalActivityRequests(wftHearbeatDeadline);
Copy link
Member

Choose a reason for hiding this comment

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

Can you help me understand what is the exact behavior today? Do we start the LA but the server fails to accept the result marker command since workflows are done? Are there any concerns that people starting LAs at end of workflow but not waiting on them still expect that code to be reached and we are not calling it anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we start the LA but the server fails to accept the result marker command since workflows are done

Correct

Are there any concerns that people starting LAs at end of workflow but not waiting on them still expect that code to be reached and we are not calling it anymore?

I don't have any concern here because if someone was starting LAs at end of workflow but not waiting on them their workflow could never complete

}
List<Command> commands = workflowStateMachines.takeCommands();
List<Message> messages = workflowStateMachines.takeMessages();
EnumSet<SdkFlag> newFlags = workflowStateMachines.takeNewSdkFlags();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,6 @@ public void handleUpdate(
// Skip validator on replay
if (!callbacks.isReplaying()) {
try {
// TODO(https://github.com/temporalio/sdk-java/issues/1748) handleValidateUpdate
// should not just be run
// in a workflow thread
workflowContext.setReadOnly(true);
workflowProc.handleValidateUpdate(updateName, input, eventId, header);
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright (C) 2022 Temporal Technologies, Inc. All Rights Reserved.
*
* Copyright (C) 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Modifications copyright (C) 2017 Uber Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this material except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.temporal.workflow;

import static org.junit.Assert.assertEquals;

import io.temporal.testing.internal.SDKTestWorkflowRule;
import io.temporal.workflow.shared.TestActivities;
import io.temporal.workflow.shared.TestWorkflows;
import java.util.Objects;
import org.junit.Rule;
import org.junit.Test;

public class CommandInTheLastWorkflowTaskTest {
@Rule
public SDKTestWorkflowRule testWorkflowRule =
SDKTestWorkflowRule.newBuilder()
.setWorkflowTypes(TestWorkflowImpl.class)
.setActivityImplementations(new TestActivities.TestActivitiesImpl())
.build();

@Test
public void testCommandInTheLastWorkflowTask() {
TestWorkflows.TestWorkflowReturnString client =
testWorkflowRule.newWorkflowStub(TestWorkflows.TestWorkflowReturnString.class);
assertEquals("done", client.execute());
}

public static class TestWorkflowImpl implements TestWorkflows.TestWorkflowReturnString {

@Override
public String execute() {
Async.procedure(
() -> {
Workflow.mutableSideEffect(
"id1", Integer.class, (o, n) -> Objects.equals(n, o), () -> 0);
});

return "done";
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* Copyright (C) 2022 Temporal Technologies, Inc. All Rights Reserved.
*
* Copyright (C) 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Modifications copyright (C) 2017 Uber Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this material except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.temporal.workflow.activityTests;

import static org.junit.Assert.assertEquals;

import io.temporal.activity.ActivityOptions;
import io.temporal.testing.internal.SDKTestWorkflowRule;
import io.temporal.workflow.Async;
import io.temporal.workflow.Workflow;
import io.temporal.workflow.shared.TestActivities;
import io.temporal.workflow.shared.TestWorkflows;
import java.time.Duration;
import org.junit.Rule;
import org.junit.Test;

public class ActivityInTheLastWorkflowTaskTest {
@Rule
public SDKTestWorkflowRule testWorkflowRule =
SDKTestWorkflowRule.newBuilder()
.setWorkflowTypes(TestWorkflowImpl.class)
.setActivityImplementations(new TestActivities.TestActivitiesImpl())
.build();

@Test
public void testActivityInTheLastWorkflowTask() {
TestWorkflows.TestWorkflowReturnString client =
testWorkflowRule.newWorkflowStub(TestWorkflows.TestWorkflowReturnString.class);
assertEquals("done", client.execute());
}

public static class TestWorkflowImpl implements TestWorkflows.TestWorkflowReturnString {

private final TestActivities.VariousTestActivities activities =
Workflow.newActivityStub(
TestActivities.VariousTestActivities.class,
ActivityOptions.newBuilder()
.setScheduleToCloseTimeout(Duration.ofSeconds(200))
.build());

@Override
public String execute() {
Async.procedure(activities::sleepActivity, (long) 1000, 0);
return "done";
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* Copyright (C) 2022 Temporal Technologies, Inc. All Rights Reserved.
*
* Copyright (C) 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Modifications copyright (C) 2017 Uber Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this material except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.temporal.workflow.activityTests;

import static org.junit.Assert.assertEquals;

import io.temporal.activity.LocalActivityOptions;
import io.temporal.testing.internal.SDKTestWorkflowRule;
import io.temporal.workflow.Async;
import io.temporal.workflow.Workflow;
import io.temporal.workflow.shared.TestActivities;
import io.temporal.workflow.shared.TestWorkflows;
import java.time.Duration;
import org.junit.Rule;
import org.junit.Test;

public class LocalActivityInTheLastWorkflowTaskTest {
@Rule
public SDKTestWorkflowRule testWorkflowRule =
SDKTestWorkflowRule.newBuilder()
.setWorkflowTypes(TestWorkflowImpl.class)
.setActivityImplementations(new TestActivities.TestActivitiesImpl())
.build();

@Test
public void testLocalActivityInTheLastWorkflowTask() {
TestWorkflows.TestWorkflowReturnString client =
testWorkflowRule.newWorkflowStub(TestWorkflows.TestWorkflowReturnString.class);
assertEquals("done", client.execute());
}

public static class TestWorkflowImpl implements TestWorkflows.TestWorkflowReturnString {

private final TestActivities.VariousTestActivities activities =
Workflow.newLocalActivityStub(
TestActivities.VariousTestActivities.class,
LocalActivityOptions.newBuilder()
.setScheduleToCloseTimeout(Duration.ofSeconds(200))
.build());

@Override
public String execute() {
Async.procedure(activities::sleepActivity, (long) 1000, 0);
return "done";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,16 @@ public interface QueryableWorkflow {
void mySignal(String value);
}

@WorkflowInterface
public interface SimpleWorkflowWithUpdate {

@WorkflowMethod
String execute();

@UpdateMethod
String update(String value);
}

@WorkflowInterface
public interface WorkflowWithUpdate {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* Copyright (C) 2022 Temporal Technologies, Inc. All Rights Reserved.
*
* Copyright (C) 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Modifications copyright (C) 2017 Uber Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this material except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.temporal.workflow.signalTests;

import static org.junit.Assert.assertEquals;

import io.temporal.activity.LocalActivityOptions;
import io.temporal.client.WorkflowStub;
import io.temporal.testing.internal.SDKTestWorkflowRule;
import io.temporal.workflow.Workflow;
import io.temporal.workflow.shared.TestActivities;
import io.temporal.workflow.shared.TestWorkflows;
import java.time.Duration;
import org.junit.Rule;
import org.junit.Test;

public class SignalWithLocalActivityInTheLastWorkflowTaskTest {
@Rule
public SDKTestWorkflowRule testWorkflowRule =
SDKTestWorkflowRule.newBuilder()
.setWorkflowTypes(TestSignalWorkflowImpl.class)
.setActivityImplementations(new TestActivities.TestActivitiesImpl())
.build();

@Test
public void testSignalWithLocalActivityInTheLastWorkflowTask() {
TestWorkflows.TestSignaledWorkflow client =
testWorkflowRule.newWorkflowStub(TestWorkflows.TestSignaledWorkflow.class);
WorkflowStub.fromTyped(client)
.signalWithStart("testSignal", new String[] {"signalValue"}, new String[] {});
assertEquals("done", client.execute());
}

public static class TestSignalWorkflowImpl implements TestWorkflows.TestSignaledWorkflow {

private final TestActivities.VariousTestActivities activities =
Workflow.newLocalActivityStub(
TestActivities.VariousTestActivities.class,
LocalActivityOptions.newBuilder()
.setScheduleToCloseTimeout(Duration.ofSeconds(200))
.build());

@Override
public String execute() {
return "done";
}

@Override
public void signal(String arg) {
activities.sleepActivity(1000, 0);
}
}
}
Loading
Loading