Skip to content

[core][actor scalability] Ensure an actor is always destroyed and not restarted when its PG is removed - #67170

Draft
Yicheng-Lu-llll wants to merge 3 commits into
ray-project:masterfrom
Yicheng-Lu-llll:yicheng/destroy-actors-on-pg-removal
Draft

Yicheng-Lu-llll wants to merge 3 commits into
ray-project:masterfrom
Yicheng-Lu-llll:yicheng/destroy-actors-on-pg-removal

Conversation

@Yicheng-Lu-llll

@Yicheng-Lu-llll Yicheng-Lu-llll commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

Description

So, this is an issue I encountered when implementing the solution for https://docs.google.com/document/d/1D_oZLa_Ek3Uq3lAQ-kOZjvxgAl26lk-wVkQcwZnqIa0/edit?tab=t.ekgpw79rflh#heading=h.9pemchlit69d, and it needs to be fixed before moving forward.

Basically, in current Ray, people typically do:

  • create a PG
  • create an actor with a PG requirement
  • remove the PG

In the current implementation, the PG removal logic hasn’t been updated for a long time and has several issues. Its current behavior is:

  • GCS sends a notification to every node that had the PG
  • the node’s raylet removes the PG and destroys the worker if the actor is alive

This causes problems like:

  • If the actor is restartable, then because it was INTENDED_SYSTEM_EXIT, it will be restarted. Since it is tied to a specific PG ID and that PG has been removed, it will never be schedulable again and will live in the scheduling loop forever, causing overhead.
  • It is possible that an actor lease is still being scheduled and has not been sent to the node that had the PG. In this case, GCS simply don’t cancel that actor lease, and it lives in the scheduling loop forever.

So, to fix the issue and also make sure we can handle GCS restarts, the new flow is as follows:

  • Write the PG removal intention to GCS table(in redis) first.
  • Then, GCS destroys every actor that require that PG(we already had func to correctly destroy actors )
    • running actors are killed through their raylet
    • pending ones have their lease request cancelled at whichever raylet holds it
  • Then the GCS tells every node that holds a bundle of the PG to release it, as before.

If GCS restarts at any point after removal intention, it will see the PG removal intention first, and since all operations are idempotent, GCS would check and simply redo all of them if needed.

If GCS restarts at any point before removal intention, client would retry.

@Yicheng-Lu-llll
Yicheng-Lu-llll force-pushed the yicheng/destroy-actors-on-pg-removal branch 5 times, most recently from adcbcd8 to 3805b2a Compare October 20, 2026 02:18
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had
any activity for 14 days. It will be closed in another 14 days if no further activity occurs.
Thank you for your contributions.

You can always ask for help on our discussion forum or Ray's public slack channel.

If you'd like to keep this open, just leave any comment, and the stale label will be removed.

@github-actions github-actions Bot added the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Nov 3, 2026
@Yicheng-Lu-llll Yicheng-Lu-llll added core Issues that should be addressed in Ray Core go add ONLY when ready to merge, run all tests and removed stale The issue is stale. It will be closed within 7 days unless there are further conversation labels Nov 11, 2026
@Yicheng-Lu-llll
Yicheng-Lu-llll force-pushed the yicheng/destroy-actors-on-pg-removal branch from 3805b2a to a66bb7d Compare November 12, 2026 00:33

@dancingactor dancingactor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR makes sense to me. Just one suggestion to reduce a performance cost this PR introduces:
This PR makes every PG removal scan all actors to find actors that belong to that PG, so the cost grows as the number of actors grows.

The fix is simple: introduce a map from PG ID to its actors in GcsActorManager.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Issues that should be addressed in Ray Core go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants