Skip to content

Commit cc9435c

Browse files
Fix race condition in ReceivePersistentActor async handlers (#7873)
Fixed a race condition in Eventsourced.RunTask() where task continuation options were incorrectly using bitwise AND instead of bitwise OR, resulting in no flags being set (AttachedToParent & ExecuteSynchronously = 0). The continuation was not executing synchronously as intended, causing async handlers to complete before sending reply messages, leading to intermittent timeout failures in tests like ReceivePersistentActorAsyncAwaitSpec. This follows historical precedent from commits cb90ed2 and e2c01f7 which removed all usage of AttachedToParent throughout the codebase. Changed TaskContinuationOptions from: AttachedToParent & ExecuteSynchronously (evaluates to 0) To: ExecuteSynchronously Fixes race condition where async message handlers would timeout waiting for reply messages that arrived after the test timeout expired.
1 parent d240738 commit cc9435c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/core/Akka.Persistence/Eventsourced.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ protected void RunTask(Func<Task> action)
577577
tcs.TrySetCanceled();
578578
else
579579
tcs.TrySetResult(null);
580-
}, TaskContinuationOptions.AttachedToParent & TaskContinuationOptions.ExecuteSynchronously);
580+
}, TaskContinuationOptions.ExecuteSynchronously);
581581

582582
t = tcs.Task;
583583
}

0 commit comments

Comments
 (0)