From 385ea37497168bd25797e98ca445d7e650736c42 Mon Sep 17 00:00:00 2001 From: Konrad Malawski Date: Fri, 21 Oct 2016 16:36:11 +0200 Subject: [PATCH] +doc,per #21689 document calling persist() in Future is unsafe (#21699) * +doc,per #21689 document calling persist() in Future is unsafe * Update persistence.rst * Update persistence.rst --- akka-docs/rst/java/persistence.rst | 7 +++++++ akka-docs/rst/scala/persistence.rst | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/akka-docs/rst/java/persistence.rst b/akka-docs/rst/java/persistence.rst index 7e2da4e589..48b70d73ef 100644 --- a/akka-docs/rst/java/persistence.rst +++ b/akka-docs/rst/java/persistence.rst @@ -326,6 +326,13 @@ In this case no stashing is happening, yet events are still persisted and callba While it is possible to nest mixed ``persist`` and ``persistAsync`` with keeping their respective semantics it is not a recommended practice, as it may lead to overly complex nesting. +.. warning:: + While it is possible to nest ``persist`` calls within one another, + it is *not* legal call ``persist`` from any other Thread than the Actors message processing Thread. + For example, it is not legal to call ``persist`` from Futures! Doing so will break the guarantees + that the persist methods aim to provide. Always call ``persist`` and ``persistAsync`` from within + the Actor's receive block (or methods synchronously invoked from there). + .. _failures-java: Failures diff --git a/akka-docs/rst/scala/persistence.rst b/akka-docs/rst/scala/persistence.rst index c724162707..cdc5d3788e 100644 --- a/akka-docs/rst/scala/persistence.rst +++ b/akka-docs/rst/scala/persistence.rst @@ -312,6 +312,13 @@ In this case no stashing is happening, yet events are still persisted and callba While it is possible to nest mixed ``persist`` and ``persistAsync`` with keeping their respective semantics it is not a recommended practice, as it may lead to overly complex nesting. +.. warning:: + While it is possible to nest ``persist`` calls within one another, + it is *not* legal call ``persist`` from any other Thread than the Actors message processing Thread. + For example, it is not legal to call ``persist`` from Futures! Doing so will break the guarantees + that the persist methods aim to provide. Always call ``persist`` and ``persistAsync`` from within + the Actor's receive block (or methods synchronously invoked from there). + .. _failures-scala: Failures