Resuming supervisor blocks further communication with children
Per Roland
it’s a bug: upon failing the Supervisor will suspends its children (though not recursively, which is also a bug), and when it is resumed, it will not pass this info on to its children.
A test program modeled after typesafe akka project , with two levels of supervisor added:
Root->Supervisor->Counter
Both Root and Supervisor have a OneForOne strategy that resumes on any exception.
Supervisor and Count throw exception on receipt of a specific message.
Error recovery proceeds as expected, generating a value of 4, IFF the Counter actor is failed at least once before the Supervisor is failed.
Failing only the Supervisor (or before failing the Counter) causes the final Get to timeout.
The Supervisor ceases to forward messages to its child.
The code to fetch the final count has been changed from the template to include a small timeout.
java version "1.7.0_03"
Java(TM) SE Runtime Environment (build 1.7.0_03-b04)
Java HotSpot(TM) 64-Bit Server VM (build 22.1-b02, mixed mode)
Scala 2.9.2
Akka 2.0.1
Fedora 15
Removing the lines marked with "must appear" causes the failure to occur.
it’s a bug: upon failing the Supervisor will suspends its children (though not recursively, which is also a bug), and when it is resumed, it will not pass this info on to its children.
A test program modeled after typesafe akka project , with two levels of supervisor added:
Root->Supervisor->Counter
Both Root and Supervisor have a OneForOne strategy that resumes on any exception.
Supervisor and Count throw exception on receipt of a specific message.
Error recovery proceeds as expected, generating a value of 4, IFF the Counter actor is failed at least once before the Supervisor is failed.
Failing only the Supervisor (or before failing the Counter) causes the final Get to timeout.
The Supervisor ceases to forward messages to its child.
The code to fetch the final count has been changed from the template to include a small timeout.
java version "1.7.0_03"
Java(TM) SE Runtime Environment (build 1.7.0_03-b04)
Java HotSpot(TM) 64-Bit Server VM (build 22.1-b02, mixed mode)
Scala 2.9.2
Akka 2.0.1
Fedora 15
Removing the lines marked with "must appear" causes the failure to occur.
import akka.actor._
import akka.pattern.ask
import akka.dispatch.Await
import akka.util.duration._
import akka.util.Timeout
import akka.actor.SupervisorStrategy._
case object Tick
case object Get
case object FailCounter
case object FailSupervisor
trait Resumer extends Actor {
override val supervisorStrategy = OneForOneStrategy(maxNrOfRetries = 10, withinTimeRange = 1 minute) {
case _ ⇒ Resume
}
}
class Root extends Resumer {
val child = context.actorOf(Props[Supervisor], name = "supervisor")
def receive = {
case _@ m => child forward m
}
}
class Supervisor extends Resumer {
val child = context.actorOf(Props[Counter], name = "counter")
def receive = {
case FailSupervisor => throw new IllegalArgumentException("supervisor")
case _@ m => child forward m
}
}
class Counter extends Actor {
var count = 0
def receive = {
case Tick => count += 1
case Get => sender ! count
case FailCounter => throw new IllegalArgumentException("counter")
}
}
object Actors extends App {
val duration = 2 seconds
implicit val timeout = Timeout(duration)
val system = ActorSystem("Actors")
val root = system.actorOf(Props[Root], name = "root")
root ! Tick
root ! FailCounter //must appear
root ! Tick
root ! FailCounter //must appear
root ! Tick
root ! FailSupervisor
root ! FailCounter
root ! Tick
println("count is", Await.result(ask(root, Get).mapTo[Int], duration))
system.shutdown()
}
Leave a comment
(In revision:2e459f5f1d6b88472118b8c479f3eded3740926a) make suspend/resume act recursively, as always intended, see #2212
Branch: wip-2212-recursive-resume-∂π
Branch: wip-2212-recursive-resume-∂π
on 2012-06-14 07:54 *
By rkuhn
Assigned to changed from rk@rkuhn.info to rkuhn
Component changed from None to actor
Milestone changed from Mingus to 2.0.3
Status changed from New to Test
Updating tickets (#2186, #2187, #2189, #2192, #2196, #2197, #2198, #2200, #2203, #2208, #2212, #2217, #2218, #2221, #2224, #2225, #2226, #2227, #2228, #2232, #2236, #2237, #2247, #2248, #2255, #2257, #2260, #2262, #2268, #2269, #2272, #2276, #2285, #2288, #2292, #2294, #2295, #2298, #2301, #2302, #2312, #2315, #2318, #2319, #2332, #2333, #2335, #2337, #2340, #2341, #2342, #2345)