Sharding issue - sharded entity is duplicated #7285
-
I created a cluster with three seed nodes, and 3 working nodes. The application aims to build a sharded entity connecting to an mqtt broker, and to keep that connection resilient across the cluster in case of nodes failures. The sharded entity is created by the region on [ConnectionConfiguration] message. In the following logs [akka.tcp://CustomApplication@host1:9998] si running the sharded entity [akka://CustomApplication/system/sharding/EdgeActorRegion/0/mosquitto%3A1883] [akka.tcp://CustomApplication@host2:9998] and [akka.tcp://CustomApplication@host2:8110] were temporarly offline, so that the cluster was composed only by seed nodes [akka.tcp://CustomApplication@host1:8110] and worker nodes [akka.tcp://CustomApplication@host1:9998] When [akka.tcp://CustomApplication@host2:9998] and [akka.tcp://CustomApplication@host2:8110] are back online the sharded entity is still running on [akka.tcp://CustomApplication@host1:9998], but it is also instantiated in [akka.tcp://CustomApplication@host2:8110]. From that moment on the two instances of the sharded entity start connecting/disconnecting from Mqtt broker, because they are sharing the same clientId. Any ideas why this could happen and how to resolve? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Related issue, which I have been investigating aggressively over the past few weeks: #6973 - mentioned it on today's Akka.NET Community Standup. This is definitely an Akka.NET bug. Let me look over your logs and data. |
Beta Was this translation helpful? Give feedback.
And what database are you using for Akka.Persistence with these settings? Any? Because by-default with this HOCON it will use the in-memory database, which is 100% why you'd receive a duplicate in this case (that in-memory database is only meant to be used for testing - it's not replicated between nodes.)
To resolve this issue, set the
ShardOptions.StateStorageMode = DData
or add a real Akka.Persistence configuration to your application.