-
Notifications
You must be signed in to change notification settings - Fork 38
Apply modern event loop algorithm with new SDK flag #432
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
Conversation
{ | ||
Apply(job); | ||
// Run scheduler once. Do not check conditions when patching or querying. | ||
var checkConditions = job.NotifyHasPatch == null && job.QueryWorkflow == null; | ||
// We only run the scheduler after each job in legacy event loop logic |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// We only run the scheduler after each job in legacy event loop logic | |
// We run the scheduler after each job in legacy event loop logic |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Meant to say "we only do X in legacy" to clarify we don't do it in non-legacy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not blocking, small comments/changes.
and just to verify my understanding:
Check all conditions at once and resolve all that are satisfied.
->
Only resolve the first condition that is satisfied and re-run the entire event loop.
we're doing this so that we can give subsequent signals (i.e. if multiple signals are sent) a chance to be handled, in the case that resolved conditions from the first signal cause the workflow to complete/terminate/finish
There's a few reasons why you don't want to tick the event loop after each job. I should have linked this to #375 which I am doing now, but also see temporalio/sdk-python#606 and we have had internal discussions on this. Basically waking up the event loop mid-job-apply causes conditions and other things to be confusingly applied too early. It becomes hard to reason about when a coroutine in a handler may run. This also aligns the event loop with other SDKs (in addition to fixing a few other things). |
Yeah I found these issues trying to gather some more context on this, very helpful. In effect, this boils down to predictable handler behavior (at least wrt to the principle bug fix). Thanks for the explanation :) |
Hi @cretz , when it will be released? |
Next .NET SDK release, but we do not have a firm date at this time, should not be too long |
What was changed
(description as mostly taken from a comment above the SDK flag)
Before this flag, workflow async logic did the following (in no particular order):
We have since learned that all of these are wrong in one way or another. So if this flag is set on the first activation/task of a workflow, the following logic now applies respectively:
We know this solves at least #427 where all-handlers-finished was improperly assumed true too early.
Checklist