syndicate-rs/syndicate/src
Tony Garnock-Jones 2d179d1e46 Avoid racy approaches to actor-termination.
They're still there: you can use turn.state.shutdown(), which enqueues
a message for eventual actor shutdown. But it's better to use
turn.stop_root(), which terminates the actor's root facet within the
current turn, ensuring that the actor's exit_status is definitely set
by the time the turn has committed.

This is necessary to avoid a racy panic in supervision: before this
change, an asynchronous SystemMessage::Release was sent when the last
facet of an actor was stopped. Depending on load (!), any retractions
resulting from the shutdown would be delivered before the Release
arrived at the stopping actor. The supervision logic expected
exit_status to be definitely set by the time release() fired, which
wasn't always true. Now that in-turn shutdown has been implemented,
this is a reliable invariant.

A knock-on change is the need to remove
enqueue_for_myself_at_commit(), replacing it with a use of
pending.for_myself.push(). The old enqueue_for_myself_at_commit
approach could lead to lost actions as follows:

    A: start linked task T, which spawns a new tokio coroutine
            T: activate some facet in A and terminate A's root facet
            T: at this point, A transitions to "not running"
    A: spawn B, enqueuing a call to B's boot()
    A: commit turn. Deliveries for others go out as usual,
       but those for A will be discarded since A is "not running".
       This means that the call to B's boot() goes missing.

Using pending.for_myself.push() instead assures that B's boot will
always run at the end of A's turn, without regard for whether A is in
some terminated state.

I think that this kind of race could have happened before, but
something about switching away from shutdown() seems to trigger it
somewhat reliably.
2022-01-10 12:52:29 +01:00
..
actor.rs Avoid racy approaches to actor-termination. 2022-01-10 12:52:29 +01:00
bag.rs Some documentation; rename Debtor to Account 2021-08-13 15:51:11 -04:00
dataflow.rs Intra-actor dataflow and fields; `enclose!` macro 2021-09-23 21:43:32 +02:00
dataspace.rs Adapt to new Preserves major version; stub daemon basis 2021-09-19 16:53:37 +02:00
during.rs stop() and stop_facet(facet_id) now return unit 2021-10-07 16:59:34 +02:00
error.rs No more distinction between internal/external protocol variants 2021-09-24 13:04:15 +02:00
lib.rs Intra-actor dataflow and fields; `enclose!` macro 2021-09-23 21:43:32 +02:00
pattern.rs Accommodate changes to dataspacePatterns 2021-12-13 15:43:24 +01:00
relay.rs It is OK for an assertion to be placed at an unregistered remote_oid, it turns out 2021-12-01 11:14:02 +01:00
rewrite.rs Fix length checks 2021-12-13 16:05:43 +01:00
skeleton.rs Accommodate changes to dataspacePatterns 2021-12-13 15:43:24 +01:00
sturdy.rs Adapt to new Preserves major version; stub daemon basis 2021-09-19 16:53:37 +02:00
supervise.rs Belt and suspenders 2022-01-09 21:01:55 +01:00
tracer.rs Put thread IDs in logging output 2022-01-10 12:52:12 +01:00