From da725818f0d5039d0ca513b6a3a20ac101f45ae5 Mon Sep 17 00:00:00 2001 From: Gregorius Soedharmo Date: Thu, 2 Jun 2022 01:16:42 +0700 Subject: [PATCH] Backport #5976 - Fix sharding tolerant reader --- .../Akka.Cluster.Sharding/PersistentShardCoordinator.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/contrib/cluster/Akka.Cluster.Sharding/PersistentShardCoordinator.cs b/src/contrib/cluster/Akka.Cluster.Sharding/PersistentShardCoordinator.cs index 3b3fc5cf843..851b633ee63 100644 --- a/src/contrib/cluster/Akka.Cluster.Sharding/PersistentShardCoordinator.cs +++ b/src/contrib/cluster/Akka.Cluster.Sharding/PersistentShardCoordinator.cs @@ -109,7 +109,12 @@ protected override bool ReceiveRecover(object message) if (State.RegionProxies.Contains(proxyTerminated.RegionProxy)) State = State.Updated(evt); return true; - case ShardHomeAllocated _: + case ShardHomeAllocated homeAllocated: + // if we already have identical ShardHomeAllocated data, skip processing it + // addresses https://github.com/akkadotnet/akka.net/issues/5604 + if (State.Shards.TryGetValue(homeAllocated.Shard, out var currentShardRegion) + && Equals(homeAllocated.Region, currentShardRegion)) + return true; State = State.Updated(evt); return true; case ShardHomeDeallocated _: