Uniqueness of persistenceId in akka-persistence
Asked Answered
D

1

6

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.

Duncan answered 14/8, 2014 at 9:27 Comment(3)
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)?Materiality
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.Duncan
This is now covered by the this ticketDuncan
D
3

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

Duncan answered 21/8, 2014 at 12:11 Comment(2)
Thanks for locating this and contributing the patch @Brendan!Flareup
My pleasure - it was good to see the process. Thanks for your patience with my inexperience of all that good stuff.Duncan

© 2022 - 2024 — McMap. All rights reserved.