Commit Graph

44 Commits

Author SHA1 Message Date
Tony Garnock-Jones b2ee8daf4b (Failed?) Experiment: alternate approach to reporting Facet::activate failures 2022-01-15 23:24:34 +01:00
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
Tony Garnock-Jones c3a9525ef1 Track enough information to allow piecing-together of parent/child relationships among actors 2022-01-10 12:52:12 +01:00
Tony Garnock-Jones 58bde1e29d Add Activation::stop_root 2022-01-10 11:23:02 +01:00
Tony Garnock-Jones 82ccbdb282 Simplify and correct facet stop logic; always run stop actions in parent facet context 2022-01-08 15:27:44 +01:00
Tony Garnock-Jones 0d25d76bec Split out (internal) on_facet_stop from on_stop 2022-01-08 15:26:34 +01:00
Tony Garnock-Jones 19b04b82a2 Improve documentation regarding stop/exit actions 2022-01-08 15:25:41 +01:00
Tony Garnock-Jones be27348d29 Activation::facet_ids 2022-01-08 15:24:10 +01:00
Tony Garnock-Jones f956f3d994 Activation::every 2022-01-07 17:15:51 +01:00
Tony Garnock-Jones 34c336e457 More tracing 2021-12-01 11:06:39 +01:00
Tony Garnock-Jones 11363c5776 If an actor panics, make sure to clean up in drop if we can 2021-12-01 11:06:29 +01:00
Tony Garnock-Jones 4713005997 wait_for_all_actors_to_stop 2021-10-08 16:37:26 +02:00
Tony Garnock-Jones baf98d6c54 Better span naming and logging tweaks 2021-10-08 16:37:17 +02:00
Tony Garnock-Jones 0d7ac7441f stop() and stop_facet(facet_id) now return unit 2021-10-07 16:59:34 +02:00
Tony Garnock-Jones f640111f20 Huh, I seem to have left this unfinished 2021-10-06 22:02:27 +02:00
Tony Garnock-Jones 2a7606d626 Track actors globally (eventually for reflection/introspection) 2021-10-05 12:39:28 +02:00
Tony Garnock-Jones ed12c0883e Switch to parking_lot for another performance boost 2021-09-30 13:32:41 +02:00
Tony Garnock-Jones de795219af Fix up daemon retry logic. Also: named fields; better stop logic.
In particular:

1. The root facet is considered inert even if it has outbound
assertions. This is because the only outbound assertion it can have is
a half-link to a peer actor, which shouldn't prevent the actor from
terminating normally if the user-level "root" facet stops.

2. On stop_facet_and_continue, parent-facet continuations execute
inline rather than at commit time. This is so that a user-level "root"
facet can *replace* itself. Remains to be properly exercised/tested.
2021-09-28 17:10:36 +02:00
Tony Garnock-Jones 013e99af70 Greatly improve service lifecycle handling 2021-09-28 12:53:18 +02:00
Tony Garnock-Jones 5a8a508fdc More general on_stop; the old behaviour is now at on_stop_notify 2021-09-24 16:14:55 +02:00
Tony Garnock-Jones ffae9be241 No more distinction between internal/external protocol variants 2021-09-24 13:04:15 +02:00
Tony Garnock-Jones 531d66205b Intra-actor dataflow and fields; `enclose!` macro 2021-09-23 21:43:32 +02:00
Tony Garnock-Jones ccd54be3b2 Adapt to new Preserves major version; stub daemon basis 2021-09-19 16:53:37 +02:00
Tony Garnock-Jones a7cb035b45 Make it possible to retract a handle from a non-current facet in the current actor 2021-09-07 19:12:32 +02:00
Tony Garnock-Jones 2cb72cd020 TODO 2021-09-07 17:28:53 +02:00
Tony Garnock-Jones e90fe2c41e Supervisor RestartPolicy 2021-09-01 17:31:01 +02:00
Tony Garnock-Jones c6e9b613e1 Don't print errors on failed send_actions in EventBuffer::deliver. 2021-08-30 23:49:08 +02:00
Tony Garnock-Jones d8c3e37d17 Supervision; delayed actions; better tracing (incl `M: Debug`); linked task release 2021-08-30 23:41:51 +02:00
Tony Garnock-Jones 5861f91971 Entity::stop, Activation::on_stop 2021-08-30 14:17:40 +02:00
Tony Garnock-Jones 1266a80696 Improve core actor tracing/logging 2021-08-30 12:08:58 +02:00
Tony Garnock-Jones 633b83412e Use tracing's macros for debug/display; enable dataspace debug 2021-08-30 12:08:58 +02:00
Tony Garnock-Jones 0f1432d414 Dynamic service instantiation 2021-08-28 18:50:55 +02:00
Tony Garnock-Jones 738ac3163a spawn_link; reactive debt_reporter service startup 2021-08-28 14:39:00 +02:00
Tony Garnock-Jones a252cfdfdf Introduce a facet immediately under the root facet for user code to run in, to allow something akin to replacement of the root facet 2021-08-27 23:38:51 +02:00
Tony Garnock-Jones 0eff672c30 Split out initial services in syndicate-server 2021-08-27 16:19:14 +02:00
Tony Garnock-Jones f56c0df10f Facets! 2021-08-27 15:31:18 +02:00
Tony Garnock-Jones ce6c46f1ae Remove actor next_task_id field 2021-08-26 12:39:08 +02:00
Tony Garnock-Jones 87338ce47a Move debt reporter into syndicate-server 2021-08-26 10:16:09 +02:00
Tony Garnock-Jones 1e12d73c50 Logging tweaks 2021-08-26 10:06:05 +02:00
Tony Garnock-Jones 4491873ac8 Docs 2021-08-13 20:16:12 -04:00
Tony Garnock-Jones aee65ea029 Finish actor.rs docs 2021-08-13 20:12:11 -04:00
Tony Garnock-Jones 931c4e5cd1 Some documentation; rename Debtor to Account 2021-08-13 15:51:11 -04:00
Tony Garnock-Jones 4f30faa1ba Split out syndicate-server crate 2021-08-12 21:42:14 -04:00
Tony Garnock-Jones 37fd904210 First reorganisation of workspace into a ... workspace 2021-08-12 21:13:49 -04:00
Renamed from src/actor.rs (Browse further)