Cluster sharding nnknown entity actor when passivating

When i do passivate, Shard doesn’t know which entity acor he should stop

def passivateEntity(): Unit = {
    log.info("Sending stop message to parent: {}", context.parent.path.toStringWithoutAddress)
    context.parent ! Passivate(stopMessage = PoisonPill)
  }

Logs:

[akka.tcp://CustomerSystem@10.244.1.149:2551/system/sharding/CustomerShard/41/50fa90e2-de5a-37c0-9c58-7fb7f1375077] k.d.m.c.e.Customer | Sending stop message to parrent: /system/sharding/CustomerShard/41
[akka.tcp://CustomerSystem@10.244.1.149:2551/system/sharding/CustomerShard/41] a.c.s.Shard | Unknown entity Actor[akka://CustomerSystem/user/$a#-903358967]. Not sending stopMessage back to entity.

actor entity with id name [akka.tcp://CustomerSystem@10.244.1.149:2551/system/sharding/CustomerShard/41/50fa90e2-de5a-37c0-9c58-7fb7f1375077] is sending stop message to context parent, but Shard receives another id name [akka://CustomerSystem/user/$a#-903358967] Why it happens?

It’s using the sender of the Passivate message. That is an implicit when using !. Could it be wrong because of the placement of your def passivateEntity? Is it right context? Maybe try tell with explicit sender? Try log context.self.

Thanx, i tried context.parent.tell(Passivate(stopMessage = PoisonPill), context.self) and it works fine. But why when i do ! sender is another entity ? def passivateEntity placed in right context

 Child: /system/sharding/CustomerShard/41/50fa90e2-de5a-37c0-9c58-7fb7f1375077 is sending stop message to parent: /system/sharding/CustomerShard/41

I think I’d need to see more of the full source code to answer that.