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

Update terminate logic to handle scheduled orchestrations #276

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cgillum
Copy link
Member

@cgillum cgillum commented Oct 11, 2024

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.

@@ -196,6 +196,7 @@ public static bool HasPayload(HistoryEvent e)
return historyEvent.EventType switch
{
EventType.ExecutionStarted => ((ExecutionStartedEvent)historyEvent).Version,
EventType.SubOrchestrationInstanceCreated => ((SubOrchestrationInstanceCreatedEvent)historyEvent).Version,
Copy link
Member Author

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])
Copy link
Collaborator

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?

Copy link
Member Author

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.

src/DurableTask.SqlServer/Scripts/logic.sql Show resolved Hide resolved
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.

Terminate Pending orchestration
2 participants