From 31e882841940f8c362b392a883eec86634efb7d9 Mon Sep 17 00:00:00 2001 From: Timon Passlick Date: Thu, 25 Jun 2026 00:29:55 +0200 Subject: [PATCH] fix state inconsistency in Orleans Chirper account (issue #7124) --- orleans/Chirper/Chirper.Grains/ChirperAccount.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/orleans/Chirper/Chirper.Grains/ChirperAccount.cs b/orleans/Chirper/Chirper.Grains/ChirperAccount.cs index 5d72315b932..b58fcc76b5b 100644 --- a/orleans/Chirper/Chirper.Grains/ChirperAccount.cs +++ b/orleans/Chirper/Chirper.Grains/ChirperAccount.cs @@ -3,10 +3,11 @@ using Microsoft.Extensions.Logging; using Orleans.Concurrency; using Orleans.Runtime; +using Orleans.Serialization.Invocation; namespace Chirper.Grains; -[Reentrant] +[MayInterleave(nameof(WontFollowAndUnfollowSimultaneously))] public sealed class ChirperAccount : Grain, IChirperAccount { /// @@ -48,6 +49,9 @@ public ChirperAccount( private static string GrainType => nameof(ChirperAccount); private string GrainKey => this.GetPrimaryKeyString(); + public static bool WontFollowAndUnfollowSimultaneously(IInvokable request) => + request.GetMethodName() is not (nameof(FollowUserIdAsync) or nameof(UnfollowUserIdAsync)); + public override Task OnActivateAsync(CancellationToken _) { _logger.LogInformation("{GrainType} {GrainKey} activated.", GrainType, GrainKey);