Skip to content

Add actor reentrancy support for HTTP and gRPC hosts - #1867

Open
2748109647 wants to merge 3 commits into
dapr:masterfrom
2748109647:feat/actor-reentrancy-1838
Open

2748109647 wants to merge 3 commits into
dapr:masterfrom
2748109647:feat/actor-reentrancy-1838

Conversation

@2748109647

@2748109647 2748109647 commented Oct 25, 2026 •

Copy link
Copy Markdown

Summary

  • Add global and per-actor reentrancy configuration (enabled and optional maxStackDepth) to HTTP actor discovery and gRPC registration.
  • Propagate Dapr-Reentrancy-Id through Reactor context for asynchronous calls, and use a scoped ThreadLocal while invoking synchronous actor methods so nested .block() calls retain the reentrancy ID. The previous value is restored when the invocation scope exits.
  • Add configuration, serialization, propagation, concurrency, and HTTP/gRPC A → B → A coverage for both asynchronous and synchronous actor methods, plus usage documentation.

Validation

  • mvn -B -pl sdk-actors test passed: 233 tests, 0 failures or errors.
  • mvn -B -pl sdk-actors -am checkstyle:check passed with 0 violations.
  • Compiled all sdk-tests integration test sources, including ActorReentrancyIT.
  • The container-backed ActorReentrancyIT was not run locally because Docker is unavailable in this environment.

Fixes #1838

Signed-off-by: Alpha <2748109647@qq.com>
@2748109647
2748109647 requested review from a team as code owners October 25, 2026 10:17
@javier-aliaga

Copy link
Copy Markdown
Contributor

@2748109647 thanks for the PR. I don't want to ship reentrancy half done, and right now the sync path doesn't work. An actor method that calls another actor with .block() never sees the Reactor context, so the call deadlocks. Our own DemoActorImpl example writes methods that way.

Could you cover the sync path in this PR as well? One option is to also keep the id in a ThreadLocal around the method invocation. It needs a sync A -> B -> A test next to the async one.

Synchronous actor methods can call another actor through a proxy that blocks
on its own subscription. Reactor context is not propagated through that path,
so the reentrancy id must be scoped around the actor method invocation and
made available to the outgoing Dapr client call.

Add a ThreadLocal fallback with nested-scope restoration and cover sync
A -> B -> A calls for both HTTP and gRPC actor hosts.

Signed-off-by: Alpha <2748109647@qq.com>
Signed-off-by: Alpha <2748109647@qq.com>

This branch has not been deployed

No deployments
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.

Support actor reentrancy (HTTP and gRPC actor host)

2 participants