Skip to content

Commit

Permalink
Avoid unnecessary shard updates while shutting down (#1342) (#1353)
Browse files Browse the repository at this point in the history
* Avoid unnecessary shard updates while shutting down

* Avoid re-creating the same message for each shard
  • Loading branch information
nvollmar authored Jun 4, 2024
1 parent d0a7293 commit 4f77c81
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1003,8 +1003,9 @@ private[pekko] class ShardRegion(
shardsByRef = shardsByRef - ref
shards = shards - shardId
startingShards -= shardId
if (settings.passivationStrategy != ClusterShardingSettings.NoPassivationStrategy) {
shards.values.foreach(_ ! ShardsUpdated(shards.size))
if (settings.passivationStrategy != ClusterShardingSettings.NoPassivationStrategy && !gracefulShutdownInProgress) {
val update = ShardsUpdated(shards.size)
shards.values.foreach(_ ! update)
}
if (handingOff.contains(ref)) {
handingOff = handingOff - ref
Expand Down Expand Up @@ -1348,7 +1349,8 @@ private[pekko] class ShardRegion(
shards = shards.updated(id, shard)
startingShards += id
if (settings.passivationStrategy != ClusterShardingSettings.NoPassivationStrategy) {
shards.values.foreach(_ ! ShardsUpdated(shards.size))
val update = ShardsUpdated(shards.size)
shards.values.foreach(_ ! update)
}
None
case Some(_) =>
Expand Down

0 comments on commit 4f77c81

Please sign in to comment.