diff --git a/src/contrib/cluster/Akka.Cluster.Sharding/PersistentShardCoordinator.cs b/src/contrib/cluster/Akka.Cluster.Sharding/PersistentShardCoordinator.cs index 645e0a6c360..ff567449a40 100644 --- a/src/contrib/cluster/Akka.Cluster.Sharding/PersistentShardCoordinator.cs +++ b/src/contrib/cluster/Akka.Cluster.Sharding/PersistentShardCoordinator.cs @@ -109,11 +109,11 @@ public IImmutableSet AllShards } /// - /// TBD + /// Feed an event into the ShardCoordinator state. /// - /// TBD - /// TBD - /// TBD + /// The event to process. + /// Thrown if an event is illegal in the current state. + /// An update copy of this state. public State Updated(IDomainEvent e) { switch (e) @@ -1361,8 +1361,12 @@ protected override bool ReceiveRecover(object message) if (CurrentState.RegionProxies.Contains(proxyTerminated.RegionProxy)) CurrentState = CurrentState.Updated(evt); return true; - case ShardHomeAllocated _: - CurrentState = CurrentState.Updated(evt); + case ShardHomeAllocated homeAllocated: + // if we already have identical ShardHomeAllocated data, skip processing it + // addresses https://github.com/akkadotnet/akka.net/issues/5604 + if(!(CurrentState.Shards.TryGetValue(homeAllocated.Shard, out var currentShardRegion) + && Equals(homeAllocated.Region, currentShardRegion))) + CurrentState = CurrentState.Updated(evt); return true; case ShardHomeDeallocated _: CurrentState = CurrentState.Updated(evt);