Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uniqueness of persistenceId in akka-persistence

I'm using the scala api for akka-persistence to persist a group of actor instances that are organized into a tree. Each node in the tree is a persistent actor and is named based on the path to that node from a 'root' node. The persistenceId is set to the name. For example the root node actor has persistenceId 'root'. The next node down has persistenceId 'root-europe'. Another actor might have persistenceId 'root-europe-italy'.

The state in each actor includes a list of the names of its children. E.g. the 'root' actor maintains a list of 'europe', 'asia' etc as part of its state.

I have implemented snapshotting for this system. When the root is triggered to snapshot, it does so and then tells each child to do the same.

The problem arises during snapshot recovery. When I re-create an actor with persistenceId = 'root' (by passing in the name as a constructor parameter), the SnapshotOffer event received by that actor is wrong. It is, for example, 'root-europe-italy....'. This seems like a contradiction of the contract for persistence, where the persistenceId identifies the actor state to be recovered. I got around this problem by reversing the persistenceId of node actors (e.g. 'italy-europe-root') so this seems to be something related to the way files are retrieved by the persistence module. Note that I tried other approaches first, for example I used a variety of separators between the node names, or no separator at all.

Has anyone else experienced this problem, or can an akka-persistence developer help me understand why this might have happened?

BTW: I am using the built-in file-based snapshot storage for now.

Thanks.

like image 802
Brendan Avatar asked Aug 14 '14 09:08

Brendan


1 Answers

OK - so the issue was with Akka, and has now been resolved. See the related ticket to find out when the patch is released.

like image 72
Brendan Avatar answered Sep 20 '22 06:09

Brendan