Skip to content

Commit

Permalink
Only isolate state when using reentrancy (#723)
Browse files Browse the repository at this point in the history
Non-reentrant actors can utilize their state manager's cache
for repeated calls. They should still be able to do this unless
using reentrancy.

Co-authored-by: Ryan Nowak <nowakra@gmail.com>
  • Loading branch information
halspang and rynowak authored Jul 22, 2021
1 parent 56ac243 commit 5e544a6
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Dapr.Actors/Runtime/ActorManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -339,10 +339,13 @@ private async Task<T> DispatchInternalAsync<T>(ActorId actorId, ActorMethodConte
T retval;
try
{
// Set the state context of the request, if possible.
if (state.Actor.StateManager is IActorContextualState contextualStateManager)
// Set the state context of the request, if required and possible.
if (ActorReentrancyContextAccessor.ReentrancyContext != null)
{
await contextualStateManager.SetStateContext(Guid.NewGuid().ToString());
if (state.Actor.StateManager is IActorContextualState contextualStateManager)
{
await contextualStateManager.SetStateContext(Guid.NewGuid().ToString());
}
}

// invoke the function of the actor
Expand Down

0 comments on commit 5e544a6

Please sign in to comment.