Repository navigation
bug: Dapr.Actors: Cancellation doesn't block turns on subseqeuent actor invocations - #1937
Merged
Merged
Conversation
…are cancelled Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
…egressions Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1937 +/- ##
==========================================
+ Coverage 65.19% 65.97% +0.77%
==========================================
Files 370 371 +1
Lines 10766 10854 +88
Branches 1262 1273 +11
==========================================
+ Hits 7019 7161 +142
+ Misses 3409 3355 -54
Partials 338 338
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
olitomlinson
added a commit
to olitomlinson/dapr-mq
that referenced
this pull request
Oct 18, 2026
When a caller cancels actor calls queued behind a running turn, the Dapr sidecar dispatches them to the app about 50ms later, while that turn is still executing (dapr/dapr#10835, reproduced in github.com/olitomlinson/dapr-actor-concurrency-repro). On the queue actor, concurrent turns overwrote each other's state: LockCount drifted from the lock rows by thousands and "Count desync" dropped the queue's priority metadata. ActorTurnGuard restores one turn at a time per actor inside the actor host, modelled on the SDK-side fix in dapr/dotnet-sdk#1937. Middleware wraps every request the sidecar sends to /actors/{type}/{id}/... and holds the turn until the SDK has finished it, state save and response included. A call in the same reentrancy chain may enter; a call whose request is aborted while it waits is dropped without running. Each time it has to step in it logs a warning naming the issue. TEMPORARY: remove it once the runtime or the SDK ships a fix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
This was referenced Oct 23, 2026
olitomlinson
added a commit
to olitomlinson/dapr-mq
that referenced
this pull request
Oct 26, 2026
…verlap The guard (#77) held one turn per actor in the host because callers cancelling queued calls made the sidecar start them while a turn was in progress (dapr/dapr#10835). The runtime fix in 1.19.0 (dapr/dapr#10842) narrows this but doesn't close it: the standalone repro on runtime 1.19.0 with Dapr.Actors 1.18.10 still overlapped in 3 of 12 cancellation trials with reentrancy off and 4 of 12 with it on. The SDK's own turn lock (dapr/dotnet-sdk#1937, in Dapr.Actors 1.19.0) closes it: on runtime and SDK 1.19.0, 0 of 24 trials overlapped. So the guard goes with this upgrade, and Dapr.Actors must stay at 1.19.0 or later. - Program.cs no longer adds the middleware; ActorTurnGuard.cs and its tests are deleted. - The issue document moves to docs/issues/resolved/ with the results above. - ADR 0003 and two proposals no longer describe the guard as current. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 26, 2026
This was referenced Oct 26, 2026
olitomlinson
added a commit
to olitomlinson/dapr-mq
that referenced
this pull request
Oct 26, 2026
…verlap The guard (#77) held one turn per actor in the host because callers cancelling queued calls made the sidecar start them while a turn was in progress (dapr/dapr#10835). The runtime fix in 1.19.0 (dapr/dapr#10842) narrows this but doesn't close it: the standalone repro on runtime 1.19.0 with Dapr.Actors 1.18.10 still overlapped in 3 of 12 cancellation trials with reentrancy off and 4 of 12 with it on. The SDK's own turn lock (dapr/dotnet-sdk#1937, in Dapr.Actors 1.19.0) closes it: on runtime and SDK 1.19.0, 0 of 24 trials overlapped. So the guard goes with this upgrade, and Dapr.Actors must stay at 1.19.0 or later. - Program.cs no longer adds the middleware; ActorTurnGuard.cs and its tests are deleted. - The issue document moves to docs/issues/resolved/ with the results above. - ADR 0003 and two proposals no longer describe the guard as current. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 26, 2026
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.
Description
@olitomlinson raised an observation that if a request was made to an actor instance and then the call cancelled while in flight, a second request will start executing its turn in the actor while the first call is still running breaking the actor turn guarantee. This applies an SDK-level lock to prevent this from occurring.
That said, this is something that should really be fixed on the runtime itself. It does not support in-flight cancellation to my knowledge, but it should also not send the SDK the second message without confirmation that the first call had completed one way or the other.
Regardless, this PR patches this behavior in lieu of explicit runtime support as this fix applies assumptions about the actor turn model.
In an abundance of caution about introducing reentrancy and concurrency errors, I've also added a small collection of new integration tests to validate this doesn't introduce regressions.
Issue reference
We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.
Please reference the issue this PR will close: #[issue number]
Checklist
Please make sure you've completed the relevant tasks for this PR, out of the following list: