Skip to content

Add support for update to the Java test server #1762

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged

Conversation

Quinn-With-Two-Ns
Copy link
Contributor

Add support for sync update to the test server.

@Quinn-With-Two-Ns Quinn-With-Two-Ns requested a review from a team as a code owner May 10, 2023 11:22
Copy link
Member

@cretz cretz left a comment

Choose a reason for hiding this comment

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

Added a couple of comments. Not reviewing too closely because 1) the tests run against real server and this server so as we find things they can just be made tests, and 2) there's gonna be a lot more coming on workflow update in the near future I'm sure

Comment on lines +1772 to +1775
// If the workflow is finished we can't write more events
// to history so if the message was processed after the workflow
// was closed there is nothing we can do.
// The real server also has this same problem
Copy link
Member

Choose a reason for hiding this comment

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

What does the client-side caller of the update see in this situation?

Would love a to see tests for workflow-complete-before-update-accept (probably have to terminate while worker not running) and workflow-complete-before-update-complete (can just hang the update handler and finish the workflow).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What does the client-side caller of the update see in this situation?

This does not impact what the caller side sees. I'll note this shouldn't be an issue once we have message commands.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would love a to see tests for workflow-complete-before-update-accept (probably have to terminate while worker not running)

I agree but we need the server to support UPDATE_WORKFLOW_EXECUTION_LIFECYCLE_STAGE_ADMITTED to write this test.

workflow-complete-before-update-complete (can just hang the update handler and finish the workflow).

I also agree, I was planning on covering this in the test server and the real server once they get support for UPDATE_WORKFLOW_EXECUTION_LIFECYCLE_STAGE_ACCEPTED

Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we should just error in workflow-completed situations then instead of silently succeeding (unless I'm misreading)

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 don't understand why we would error. I am emulating the real server and the real server does not error. Erroring would also not help us?

Copy link
Member

@cretz cretz May 10, 2023

Choose a reason for hiding this comment

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

I thought the real server just improperly handled this. Surely an update will error when workflow closed while processing when the real server is completed. I was just saying error here as "not-yet-properly implemented on real server so it intentionally isn't here either" until we see the shape that error takes. But we can just silently swallow now I guess too so long as we're willing to revisit with those two test scenarios before GA.

Copy link
Contributor

Choose a reason for hiding this comment

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

There is an intentional implementation on the server as of yesterday. The guarantee is that a WFTCompletion will get an error back if there are any incomplete updates. If the workflow execution completed command comes in the same WFT as the update completion, that is allowed and the WFE can complete.

HOWEVER

Further discussion with the server team revealed that a different behavior is desired: we will (soon) prevent the WFE from completing only if there are updates that have not been seen by workflow code yet. In practice this means that updates in the admitted or requested state will prevent WFE completion. If we know that the workflow code has seen the update request (accepted or completed states) then the thinking is that the workflow had a chance to prevent it's own completion but chose not to do so and thus we let the completion go through and the update will never complete.

@Quinn-With-Two-Ns Quinn-With-Two-Ns merged commit e354d1f into temporalio:master May 10, 2023
private static void bufferUpdate(
RequestContext ctx, WorkflowTaskData data, UpdateWorkflowExecution update, long notUsed) {
if (data.getUpdateRequest(update.getId()).isPresent()) {
throw Status.INTERNAL
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this bubble back to the submitting client as an error?

Comment on lines +1772 to +1775
// If the workflow is finished we can't write more events
// to history so if the message was processed after the workflow
// was closed there is nothing we can do.
// The real server also has this same problem
Copy link
Contributor

Choose a reason for hiding this comment

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

There is an intentional implementation on the server as of yesterday. The guarantee is that a WFTCompletion will get an error back if there are any incomplete updates. If the workflow execution completed command comes in the same WFT as the update completion, that is allowed and the WFE can complete.

HOWEVER

Further discussion with the server team revealed that a different behavior is desired: we will (soon) prevent the WFE from completing only if there are updates that have not been seen by workflow code yet. In practice this means that updates in the admitted or requested state will prevent WFE completion. If we know that the workflow code has seen the update request (accepted or completed states) then the thinking is that the workflow had a chance to prevent it's own completion but chose not to do so and thus we let the completion go through and the update will never complete.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants