Skip to content

Commit

Permalink
de-duplicate only identical ShardHomeAllocated messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaronontheweb committed May 31, 2022
1 parent 7323678 commit 0d6325a
Showing 1 changed file with 10 additions and 6 deletions.
Expand Up @@ -109,11 +109,11 @@ public IImmutableSet<ShardId> AllShards
}

/// <summary>
/// TBD
/// Feed an event into the ShardCoordinator state.
/// </summary>
/// <param name="e">TBD</param>
/// <exception cref="ArgumentException">TBD</exception>
/// <returns>TBD</returns>
/// <param name="e">The event to process.</param>
/// <exception cref="ArgumentException">Thrown if an event is illegal in the current state.</exception>
/// <returns>An update copy of this state.</returns>
public State Updated(IDomainEvent e)
{
switch (e)
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 0d6325a

Please sign in to comment.