Prevent ContinueAsNew from overriding termination - #1409
Open
wangbill (YunchuWang) wants to merge 3 commits into
Open
wangbill (YunchuWang) wants to merge 3 commits into
wangbill (YunchuWang) wants to merge 3 commits into
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: a050d04d-d7f9-4d0f-8084-a2daa7000df4
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Move the test file into the active lowercase project path so it is compiled and executed on case-sensitive checkouts.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
Updates orchestration completion so termination takes precedence over ContinueAsNew, with regression coverage for event ordering and dispatcher behavior.
Changes:
- Prioritizes terminal completion over continuation.
- Adds termination-race regression tests.
- Test file is outside the active lowercase test project path.
| File | Summary |
|---|---|
Test/DurableTask.Core.Tests/ContinueAsNewTerminationTests.cs |
Adds termination and continuation regression tests. |
src/DurableTask.Core/TaskOrchestrationContext.cs |
Makes terminal completion authoritative. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: a050d04d-d7f9-4d0f-8084-a2daa7000df4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Prevent ContinueAsNew from overriding termination
Keep termination authoritative when a timer-fired event and a termination event arrive in the same work item. A pending
ContinueAsNewcurrently bypasses the existing terminal guard, allowing the executor to return bothTerminatedandContinuedAsNew. The dispatcher can then start another generation even though the runtime state retained the termination marker.Changes
TaskOrchestrationContext.CompleteOrchestration; leave normal continuation, completion, and failure behavior unchanged.Validation
Local regression coverage
net8.0andnet48.net8.0. After correcting the test path casing, all 11 regression cases were rerun successfully on both frameworks:The earlier adjacent-test run on
net48had seven existing trace-activity failures. All seven were reproduced on the unpatched baseline, including when running the existing tracing tests alone; they are not changed here. Full repository/provider suites and hosted CI/CodeQL have not been run locally.Bounded Azure validation of the proposed patch
Compared published Core
3.10.0with private candidate3.10.0-pr1409.e8ba6d46, built from this PR'se8ba6d46commit, in disposable Azure Functions applications using in-process and .NET isolated execution. Candidate assembly hashes and source-commit metadata were verified in the in-process host and isolated worker; the isolated host's deployed candidate assembly was also verified. All non-Core package identities and hashes matched within each pair.Direct coverage of a timer and termination in the same fetched work item came from one candidate in-process smoke case and two candidate isolated cases (one formal, one smoke). Each persisted exactly one
Terminatedcompletion, retained the execution ID, emitted no new ContinueAsNew, and remained terminated through an eight-second stability check and final inventory. The in-process candidate formal sweep did not produce a co-batch; its zero-loss result alone is not evidence of that path.The patched cloud co-batches observed TimerFired before termination; the reverse order is covered by local regression tests.
Candidate formal runs had no conflicting-completion log, original duplicate-completion exception, or status reversion. Three candidate cases where ordinary completion won were not classified as continuation losses. All 20 no-termination controls completed after five normal continuations. All 152 formal and smoke instances reached terminal status.
These are bounded functional results, not failure-rate estimates or proof against every timing interleaving. The applications carried no customer traffic; this was a custom candidate validation, not a customer production deployment or a released package. Model-specific host runtimes and candidate/control compiler, signing, and release-build differences remain comparison limitations.
Related Issues
Related to Azure/azure-functions-durable-extension#2264.
Compatibility and rollout
This addresses the conflicting-completion path within one event batch, not every provider termination-timing scenario.
No package-version bump or downstream dependency update is included. The private candidate is not published to NuGet. For .NET isolated workers, the fixed Core version must also reach the worker SDK dependency that runs the executor; a host-only Core upgrade is insufficient, even though both were explicitly overridden for this validation.