Register named remote actors and avoid late PgLeave respawns#421
Open
adamrobbie wants to merge 4 commits into
Open
Register named remote actors and avoid late PgLeave respawns#421adamrobbie wants to merge 4 commits into
adamrobbie wants to merge 4 commits into
Conversation
Author
|
And thank you for a library like this. |
added 2 commits
April 23, 2026 15:37
- ActorCell::new_remote now logs a warning and skips registration when the name is already taken, rather than returning a SpawnErr. The shim is still spawned and reachable by pid. - Document that ActorRef::<T>::where_is returns None for remote actors because they are typed as RemoteActorMessage internally; callers should use registry::where_is directly for remote lookups. - Add regression test: remote spawn with a colliding local name must not fail and must not evict the local actor from the registry.
Stop respawning the RemoteActor shim immediately when it panics. Respawning with the same pid reintroduces stale-message races and registry name collisions. The remote node controls re-announcement via a new Spawn control message. Also adds actor_failed_does_not_respawn_remote_actor regression test.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #421 +/- ##
==========================================
+ Coverage 86.00% 86.22% +0.21%
==========================================
Files 73 73
Lines 13564 13791 +227
==========================================
+ Hits 11666 11891 +225
- Misses 1898 1900 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Owner
|
can you fix the failing tests? Then I'm happy to review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR makes named remote actors visible in the local named registry, matching the behavior of local actors. It also closes several lifecycle safety gaps that would have caused registry collisions and stale-message races.
Motivation
Addresses #93: "Remote actors don't appear in the local registry".
Remote actors already behave like local actors in most ways, but their names were not exposed through
ractor::registry::where_is(...). That made name-based lookup inconsistent and reduced the usefulness of remote actors in cluster setups.What changed
ractor/src/actor/actor_cell.rsActorCell::new_remotewarn!and skip registration instead of returning a hardSpawnErr. The shim is still spawned and reachable by pid.ractor/src/actor/actor_ref.rsActorRef::<T>::where_isreturnsNonefor remote actors because remote shims are typed asRemoteActorMessageinternally. Callers should useregistry::where_isdirectly for untyped remote lookups.ractor_cluster/src/node/node_session.rsActorFailedfor a remote shim: kill and remove without immediately respawning. Respawning with the same pid reintroduces stale-message races and registry collisions; the remote node controls re-announcement via a newSpawncontrol message.PgLeavefor an unknown pid: log a debug message and skip instead of recreating the shim. If the actor already terminated locally, group membership was already cleaned up by the shutdown path.PID registry behavior unchanged:
Regression tests added
registry::where_is(...)and is removed on shutdownActorFailedon a remote shim does not respawn itPgLeaveafter remote actor termination does not respawn the shimTesting
cargo fmt --allcargo clippy --all -- -D clippy::all -D warningscargo test -p ractor --features cluster remote_actor_with_name_is_registered -- --nocapturecargo test -p ractor --features cluster remote_actor_name_collision_with_local_does_not_fail_spawn -- --nocapturecargo test -p ractor_cluster node_session_handle_control -- --nocapturecargo test -p ractor_cluster actor_failed_does_not_respawn_remote_actor -- --nocapturecargo test -p ractor_cluster pg_leave_after_terminate_does_not_respawn_remote_actor -- --nocapture