6
votes

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.

1
Sounds strange. I would like to see a minimized example that reproduces the problem. Perhaps you can open an issue: github.com/akka/akka/issues Do you use latest version (2.3.4 or 2.3.5)?Patrik Nordwall
It is a strange one alright. Very unexpected. I'm using version 2.3.4 at the moment. I'll open an issue as suggested and see if I can provide more detail that will allow the problem to be reproduced easily.Brendan
This is now covered by the this ticketBrendan

1 Answers

3
votes

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