Commit Graph

38 Commits

Author SHA1 Message Date
Tony Garnock-Jones 3c44768a72 Convenience syndicate::relay::stdio_service 2024-03-30 11:00:22 +01:00
Tony Garnock-Jones 0b72b4029b Repair reimported, attenuated references. 2024-03-22 20:51:02 +01:00
Tony Garnock-Jones f4a4b4d595 Reuse a single Activation per actor: this merges RunningActor with Activation 2024-03-04 10:07:31 +01:00
Tony Garnock-Jones 1ff222b291 Demote terminate-on-drop to a debug message rather than an error 2024-02-24 13:08:32 +01:00
Tony Garnock-Jones e501d0f76a Repair warnings 2024-02-24 13:06:22 +01:00
Tony Garnock-Jones 9a148ecfcc Good grief, I forgot to update the preserves crate versions 2023-10-18 22:50:54 +02:00
Tony Garnock-Jones 4dca1b1615 More updates to gatekeeper protocol 2023-02-09 00:17:12 +01:00
Tony Garnock-Jones 00c99d96df Simplify 2023-02-08 22:35:34 +01:00
Tony Garnock-Jones 6ec6bbaf41 Incorporate Step, Description 2023-02-08 22:27:41 +01:00
Tony Garnock-Jones 7e8dcef0e2 Refactor gatekeeper implementation for new protocols. 2023-02-08 18:01:51 +01:00
Tony Garnock-Jones 833be7b293 Update attenuations 2023-02-06 14:48:18 +01:00
Tony Garnock-Jones 94040ae566 More ergonomic guard api 2023-01-30 17:29:25 +01:00
Tony Garnock-Jones c3571a2faf Expose a more flexible interface to relays 2023-01-30 17:28:20 +01:00
Tony Garnock-Jones dbbbc8c1c6 Breaking change: much improved error API 2023-01-30 14:25:58 +01:00
Tony Garnock-Jones b5564979f0 Repair error in sync handling 2023-01-09 09:20:58 +01:00
Tony Garnock-Jones f88592282d MAJOR REFACTORING OF CORE ASSERTION-TRACKING STRUCTURES. Little impact on API. Read on for details.
2022-02-01 15:22:30 Two problems.

 - If a stop action panics (in `_terminate_facet`), the Facet is dropped before its outbound
   handles are removed. With the code as it stands, this leaks assertions (!!).

 - The logic for removing an outbound handle seems to be running in the wrong facet context???
   (See `f.outbound_handles.remove(&handle)` in the cleanup actions
    - I think I need to remove the for_myself mechanism
    - and add some callbacks to run only on successful commit

2022-02-02 12:12:33 This is hard.

Here's the current implementation:

 - assert
    - inserts into outbound_handles of active facet
    - adds cleanup action describing how to do the retraction
    - enqueues the assert action, which
       - calls e.assert()

 - retract
    - looks up & removes the cleanup action, which
       - enqueues the retract action, which
          - removes from outbound_handles of the WRONG facet in the WRONG actor
          - calls e.retract()

 - _terminate_facet
    - uses outbound_handles to retract the facet's assertions
    - doesn't directly touch cleanup actions, relying on retract to do that
    - if one of a facet's stop actions panics, will drop the facet, leaking its assertions
    - actually, even if a stop action yields `Err`, it will drop the facet and leak assertions
    - yikes

 - facet drop
    - panics if outbound_handles is nonempty

 - actor cleanup
    - relies on facet tree to find assertions to retract

Revised plan:

 - ✓ revise Activation/PendingEvents structures
    - rename `cleanup_actions` to `outbound_assertions`
    - remove `for_myself` queues and `final_actions`
    - add `pre_commit_actions`, `rollback_actions` and `commit_actions`

 - ✓ assert
    - as before
    - but on rollback, removes from `outbound_handles` (if the facet still exists) and
      `outbound_assertions` (always)
    - marks the new assertion as "established" on commit

 - ✓ retract
    - lookup in `outbound_assertions` by handle, using presence as indication it hasn't been
      scheduled in this turn
    - on rollback, put it back in `outbound_assertions` ONLY IF IT IS MARKED ESTABLISHED -
      otherwise it is a retraction of an `assert` that has *also* been rolled back in this turn
    - on commit, remove it from `outbound_handles`
    - enqueue the retract action, which just calls e.retract()

 - ✓ _terminate_facet
    - revised quite a bit now we rely on `RunningActor::cleanup` to use `outbound_assertions`
      rather than the facet tree.
    - still drops Facets on panic, but this is now mostly harmless (reorders retractions a bit)
    - handles `Err` from a stop action more gracefully
    - slightly cleverer tracking of what needs doing based on a `TerminationDirection`
    - now ONLY applies to ORDERLY cleanup of the facet tree. Disorderly cleanup ignores the
      facet tree and just retracts the assertions willy-nilly.

 - ✓ facet drop
    - warn if outbound_handles is nonempty, but don't do anything about it

 - ✓ actor cleanup
    - doesn't use the facet tree at all.
    - cleanly shutting down is done elsewhere
    - uses the remaining entries in `outbound_assertions` (previously `cleanup_actions`) to
      deal with retractions for dropped facets as well as any other facets that haven't been
      cleanly shut down

 - ✓ activate
    - now has a panic_guard::PanicGuard RAII for conveying a crash to an actor in case the
      activation is happening from a linked task or another thread (this wasn't the case in the
      examples that provoked this work, though)
    - simplified
    - explicit commit/rollback decision

 - ✓ Actor::run
    - no longer uses the same path for crash-termination and success-termination
    - instead, for success-termination, takes a turn that calls Activation::stop_root
       - this cleans up the facet tree using _terminate_facet
       - when the turn ends, it notices that the root facet is gone and shuts down the actor
       - so in principle there will be nothing for actor cleanup to do

2022-02-04 13:52:34 This took days. :-(
2022-02-04 13:59:37 +01:00
Tony Garnock-Jones 1244e416d0 clear/deliver -> rollback/commit, and don't commit on drop 2022-02-02 12:10:13 +01:00
Tony Garnock-Jones 70c442ad47 Use a named unit struct instead of () 2022-01-26 23:37:21 +01:00
Tony Garnock-Jones 4dc613a091 Foundations for causal tracing 2022-01-19 14:40:50 +01:00
Tony Garnock-Jones 650463ff20 Accommodate extension point 2022-01-17 00:32:16 +01:00
Tony Garnock-Jones 3d3c1ebf70 Better handling of activation after termination, which repairs a scary-looking-but-harmless panic in config_watcher's private thread 2022-01-16 00:02:33 +01:00
Tony Garnock-Jones 730fa2098b 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
Tony Garnock-Jones 34c336e457 More tracing 2021-12-01 11:06:39 +01:00
Tony Garnock-Jones 2ec35ad868 Process the rest of the turn even when an unknown oid is seen 2021-10-18 17:21:09 +02:00
Tony Garnock-Jones ac6f37cf0c Clean up error reporting 2021-10-07 18:10:59 +02:00
Tony Garnock-Jones 7117215963 Binary and text support 2021-10-05 21:11:16 +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 013e99af70 Greatly improve service lifecycle handling 2021-09-28 12:53:18 +02:00
Tony Garnock-Jones a263a7091d Tweak debug outputs 2021-09-26 11:02: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 ccd54be3b2 Adapt to new Preserves major version; stub daemon basis 2021-09-19 16:53:37 +02:00
Tony Garnock-Jones b5b1a6883c Repair reference-counting across membranes. 2021-09-08 13:11:54 +02:00
Tony Garnock-Jones 7aa67adfbf Use deserialize to avoid a bunch of useless work and code 2021-09-07 23:07:03 +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 f56c0df10f Facets! 2021-08-27 15:31:18 +02:00
Tony Garnock-Jones 931c4e5cd1 Some documentation; rename Debtor to Account 2021-08-13 15:51:11 -04:00
Tony Garnock-Jones 82dd821d35 Default to binary (!) 2021-08-12 23:58:38 -04:00
Tony Garnock-Jones 37fd904210 First reorganisation of workspace into a ... workspace 2021-08-12 21:13:49 -04:00
Renamed from src/relay.rs (Browse further)