Skip to content

Commit 5e544a6

Browse files
halspangrynowak
andauthored
Only isolate state when using reentrancy (#723)
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 <[email protected]>
1 parent 56ac243 commit 5e544a6

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/Dapr.Actors/Runtime/ActorManager.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,10 +339,13 @@ private async Task<T> DispatchInternalAsync<T>(ActorId actorId, ActorMethodConte
339339
T retval;
340340
try
341341
{
342-
// Set the state context of the request, if possible.
343-
if (state.Actor.StateManager is IActorContextualState contextualStateManager)
342+
// Set the state context of the request, if required and possible.
343+
if (ActorReentrancyContextAccessor.ReentrancyContext != null)
344344
{
345-
await contextualStateManager.SetStateContext(Guid.NewGuid().ToString());
345+
if (state.Actor.StateManager is IActorContextualState contextualStateManager)
346+
{
347+
await contextualStateManager.SetStateContext(Guid.NewGuid().ToString());
348+
}
346349
}
347350

348351
// invoke the function of the actor

0 commit comments

Comments
 (0)