Skip to content

fix(actors): Recreate actor object when Dapr reports a new activation - #1876

Merged
javier-aliaga merged 6 commits into
dapr:masterfrom
cicoyle:fix-sidecar-restart-overwrite-actor
Nov 3, 2026
Merged

javier-aliaga merged 6 commits into
dapr:masterfrom
cicoyle:fix-sidecar-restart-overwrite-actor

Conversation

@cicoyle

@cicoyle cicoyle commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Pairs with the dapr/dapr change that sends Dapr-Actor-Activation-Id on actor callbacks.

After daprd is killed the app keeps its actor objects, and the new daprd never sends DELETE for them. The SDK reused the stale object, skipped onActivate and kept its in-memory fields.

  • new id: onDeactivate the old object (errors logged), activate a fresh one
  • same id or no id (older daprd): reuse, same as today
  • a call on a replaced or deleted object still runs onPostActorMethod, then skips the save and fails with IllegalStateException
  • a late first activation never replaces a newer one, a different id fails
  • ActorRuntime and DaprController get overloads with the id, old signatures still work
  • HTTP only, this SDK has no gRPC actor callback stream

Not covered: a save already in flight can still land late. Etags on actor state are a follow-up.

Signed-off-by: Cassandra Coyle <cassie@diagrid.io>
Signed-off-by: Cassandra Coyle <cassie@diagrid.io>
Copilot AI balanced review requested due to automatic review settings October 26, 2026 20:18
@cicoyle
cicoyle requested review from a team as code owners October 26, 2026 20:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

…ctivation

Signed-off-by: Cassandra Coyle <cassie@diagrid.io>
Copilot AI balanced review requested due to automatic review settings October 26, 2026 21:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@nelson-parente nelson-parente left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#1840 added the gRPC actor event stream after this branched. ActorEventDispatcher on master calls runtime.invoke, invokeReminder and invokeTimer without the activation id, so stream-hosted actors keep the stale object. Can you rebase and pass the id from request.getMetadata() there?

Signed-off-by: Cassandra Coyle <cassie@diagrid.io>
Copilot AI balanced review requested due to automatic review settings October 27, 2026 15:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

Signed-off-by: Cassandra Coyle <cassie@diagrid.io>
Copilot AI balanced review requested due to automatic review settings October 27, 2026 17:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

Signed-off-by: Cassandra Coyle <cassie@diagrid.io>
Copilot AI balanced review requested due to automatic review settings October 29, 2026 14:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@codecov

codecov Bot commented Oct 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.75177% with 43 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.94%. Comparing base (84aa4d7) to head (70e51ad).

Files with missing lines Patch % Lines
...java/io/dapr/actors/runtime/ActorStateManager.java 71.79% 23 Missing and 10 partials ⚠️
.../java/io/dapr/actors/runtime/ActivationIdGate.java 90.38% 2 Missing and 3 partials ⚠️
...in/java/io/dapr/actors/runtime/DaprClientImpl.java 0.00% 3 Missing ⚠️
...a/io/dapr/actors/runtime/ActorEventDispatcher.java 90.90% 0 Missing and 1 partial ⚠️
...main/java/io/dapr/actors/runtime/ActorManager.java 98.70% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1876      +/-   ##
============================================
+ Coverage     80.69%   80.94%   +0.25%     
- Complexity     2851     2922      +71     
============================================
  Files           275      276       +1     
  Lines          8459     8591     +132     
  Branches        911      930      +19     
============================================
+ Hits           6826     6954     +128     
+ Misses         1266     1265       -1     
- Partials        367      372       +5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@javier-aliaga
javier-aliaga merged commit de80f1f into dapr:master Nov 3, 2026
23 of 24 checks passed
@dapr-bot

dapr-bot commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

The backport to release-1.19 failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-release-1.19 release-1.19
# Navigate to the new working tree
cd .worktrees/backport-release-1.19
# Create a new branch
git switch --create backport-1876-to-release-1.19
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 de80f1f0b0e9d84a0a892f68280af2611eb2f04f
# Push it to GitHub
git push --set-upstream origin backport-1876-to-release-1.19
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-release-1.19

Then, create a pull request where the base branch is release-1.19 and the compare/head branch is backport-1876-to-release-1.19.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants