This is an automated email from the ASF dual-hosted git repository.

nvollmar pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pekko.git


The following commit(s) were added to refs/heads/main by this push:
     new 92b38e72d6 Avoid unnecessary shard updates while shutting down (#1342)
92b38e72d6 is described below

commit 92b38e72d6a2701da06f483e8cd27953e403240e
Author: Nicolas Vollmar <[email protected]>
AuthorDate: Tue Jun 4 07:41:44 2024 +0200

    Avoid unnecessary shard updates while shutting down (#1342)
    
    * Avoid unnecessary shard updates while shutting down
    
    * Avoid re-creating the same message for each shard
---
 .../scala/org/apache/pekko/cluster/sharding/ShardRegion.scala     | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git 
a/cluster-sharding/src/main/scala/org/apache/pekko/cluster/sharding/ShardRegion.scala
 
b/cluster-sharding/src/main/scala/org/apache/pekko/cluster/sharding/ShardRegion.scala
index 169f71d464..20e9a8f3a1 100644
--- 
a/cluster-sharding/src/main/scala/org/apache/pekko/cluster/sharding/ShardRegion.scala
+++ 
b/cluster-sharding/src/main/scala/org/apache/pekko/cluster/sharding/ShardRegion.scala
@@ -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
@@ -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(_) =>


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to