Akka sharding and persistence recovery

I am trying to figure out how akka sharding and persistence play together.
Suppose there is an SomeActor with persistenceId = "SomeActor-"+self.path.name and cassandra journal. Also we start ClusterSharding with extractEntityId equals to some business entity id.

What is interesting is how the recovery process will occur in case cluster has been shutdowned and then restarted.
Will it try to recover all actors state at once after restart? But in that case akka-persistence needs to know persistenceId to replay events from cassandra, but how we get persistenceId if it bounds to actor path itself (and actor is created when first message comes ??? ).I am just confused with it.

Thanks in advance for explanation!

Surely using self.path.name as part of the persistenceId will result in a race condition, as the name of a persistent actor is usually the persistenceId!

I don’t get the point.
self.path.name is used to distinguish entity sharding actors.
In akka sharding the name of each entity will be different e.g.
akka://local/system/sharding/some-actor/1/34f9a1d2-3a16-5fe0-96b0-73cf397106d2

so normally your persistenceId would contain the “business entity id” so that akka persistence can find the actor that is responsible for this business entity.

So if you have an account 766FF428-01E8-4D91-AB5F-261541B11767 then you’d have a persistenceId like "account-766FF428-01E8-4D91-AB5F-261541B11767" and your messages should have a field that allows the "extractEntityId" to find "766FF428-01E8-4D91-AB5F-261541B11767"