-
Notifications
You must be signed in to change notification settings - Fork 33
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
Update terminate logic to handle scheduled orchestrations #276
base: main
Are you sure you want to change the base?
Conversation
@@ -196,6 +196,7 @@ public static bool HasPayload(HistoryEvent e) | |||
return historyEvent.EventType switch | |||
{ | |||
EventType.ExecutionStarted => ((ExecutionStartedEvent)historyEvent).Version, | |||
EventType.SubOrchestrationInstanceCreated => ((SubOrchestrationInstanceCreatedEvent)historyEvent).Version, |
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.
This is an unrelated fix that I happened to notice independently. I'm just adding it to this PR as a convenience since it's a small change.
IF @Reason IS NOT NULL | ||
-- Note that we don't use the Reason column for the Reason with terminate events | ||
SET @PayloadID = NEWID() | ||
INSERT INTO Payloads ([TaskHub], [InstanceID], [PayloadID], [Text]) |
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.
The comment in line#468 states that the table order for this sproc should be Instances --> (NewEvents --> Payloads --> NewEvents) but this PR changes the table order to Instances --> (Payloads --> Instances --> NewEvents).
Does this present a concern for deadlocks, and if not, should we update the comment to reflect the new ordering?
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.
Hmm...good observation. Let me take a closer look at this.
Fixes #178
This updates the SQL-based terminate logic to handle the case where users try to terminate scheduled orchestrations. We can't use the previous approach of sending an
ExecutionTerminated
message because DTFx doesn't know how to handle the case where this message is received and there is no orchestration state (you end up with a repeating NullReferenceException until the scheduled orchestration actually starts).This PR also includes an integration test for this scenario.