akka/akka-core

Persistent actor stops receiving messages after a nested call to persist.

Open

#23,781 opened on Oct 4, 2017

View on GitHub
 (6 comments) (0 reactions) (0 assignees)Scala (3,547 forks)batch import
1 - triagedhelp wantedt:persistence

Repository metrics

Stars
 (13,277 stars)
PR merge metrics
 (Avg merge 8d 19h) (10 merged PRs in 30d)

Description

Hi.

Whilst experimenting with akka I stumbled into some unexpected behaviour, where it seemed some actors stopped receiving messages. I eventually narrowed the problem down to a nested persist call, and I've created a project to explore the problem a bit more.

The exact behaviour I am seeing is as follows:

  • Send an actor some messages that it processes normally.
  • Send the actor a message which results in a call to a persist, which is nested inside of a deferAsync call.
  • Send the actor a message. It will process this message normally.
  • Send the actor further messages. The actor will receive none of these messages, but does not seem to have terminated either.

After testing, this seems to happen if you have a call to persist within a call to either deferAsync or persistAsync. Under the akka documentation section on nested persist calls, it mentions that you may nest mixed persist and persistAsync calls, though it does warn against this. However it seems particularly strange to me that the actor will gladly handle one and only one more message after the nested calls without issue.

Perhaps I have misunderstood the intention of the documentation, in which case apologies for the pointless ticket. On the positive side of things, running into this problem did make me realise that the way I was trying to solve a particular problem at the time was rather silly, so thanks for that.

Project link: https://github.com/DanielMoss/akka-persistence-experiment/tree/master Docs link: https://doc.akka.io/docs/akka/2.5.6/scala/persistence.html#nested-persist-calls

Contributor guide