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

Job ordering updates #789

Merged
merged 8 commits into from
Aug 16, 2024

Conversation

Sushisource
Copy link
Member

@Sushisource Sushisource commented Aug 9, 2024

What was changed

Make UpdateRandomSeed jobs come after start workflow, but before everything else.

Why?

These could technically have consequences for later actions, and should go first. It's intuitive.

The more delicate change here is actually sorting StartWorkflow before other stuff, which also seems intuitive, but a number of tests at least in core had some expectations around updates being able to come first. Frankly, that doesn't make a ton of sense, and I don't really expect this move to be any kind of real issue, but it might require some changes to langs that are using StartWorkflow as a synonym for "do first iteration of the event loop"? If such changes are needed, they should be the ones described here: temporalio/sdk-python#606 (.NET may need an equivalent item) as none of these problems exist if all jobs are all read and applied to state first, before doing any iterating of the event loop.

Checklist

  1. Closes [Bug] UpdateRandomSeed jobs should go first with patches #790

  2. How was this tested:
    Updated existing tests

  3. Any docs updates needed?

@Sushisource Sushisource force-pushed the update-seed-jobs-first branch from 608661f to 856a848 Compare August 15, 2024 23:21
@Sushisource Sushisource changed the title Ensure update random seed jobs go first with patches Job ordering updates Aug 16, 2024
@Sushisource Sushisource marked this pull request as ready for review August 16, 2024 00:32
@Sushisource Sushisource requested a review from a team as a code owner August 16, 2024 00:32
Comment on lines 1367 to 1370
workflow_activation_job::Variant::StartWorkflow(_) => 1,
workflow_activation_job::Variant::UpdateRandomSeed(_) => 2,
workflow_activation_job::Variant::SignalWorkflow(_) => 3,
workflow_activation_job::Variant::DoUpdate(_) => 3,
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this works. I think signal/update in the same task as start always need to come before start. It's important for data loss reason that signal/update handlers run before the primary method.

Copy link
Member Author

Choose a reason for hiding this comment

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

Lengthy discussion outside of the PR summarized:

This change's impetus is to make the sending of information be appropriately ordered, and lang can always assume that a main routine ought to be started at the end of the first activation.

workflow_activation_job::Variant::SignalWorkflow(_) => 2,
workflow_activation_job::Variant::DoUpdate(_) => 2,
workflow_activation_job::Variant::NotifyHasPatch(_) => 0,
workflow_activation_job::Variant::InitializeWorkflow(_) => 1,
Copy link
Member

Choose a reason for hiding this comment

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

I was under the impression the contract now was that this should always be the first job on the activation, so I wonder if this should be 0 and notify has patch should be 1

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I suppose there's really no reason not to do that. Will change.

@Sushisource Sushisource merged commit 5462522 into temporalio:master Aug 16, 2024
6 checks passed
@Sushisource Sushisource deleted the update-seed-jobs-first branch August 16, 2024 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] UpdateRandomSeed jobs should go first with patches
2 participants