Skip to content

[Core] Fix a check failure where removing PG fails to return the PG resources - #53195

Merged
jjyao merged 1 commit into
ray-project:masterfrom
jjyao:jjyao/ppggfix
May 21, 2025
Merged

jjyao merged 1 commit into
ray-project:masterfrom
jjyao:jjyao/ppggfix

Conversation

@jjyao

@jjyao jjyao commented May 21, 2025 •

Copy link
Copy Markdown
Contributor

Why are these changes needed?

Example of sequence of events that causes this check failure is:

  • A single 1 CPU bundle PG is created -> (PG_CPU_RESOURCE: [1/1])
  • A 1 CPU actor is created and used that 1 CPU from the PG -> (PG_CPU_RESOURCE: [0/1])
  • Another 1 CPU actor is created and its worker lease request is added to the local task manager dispatch queue since there is no available PG resources (already used by the first actor).
  • The PG is manually removed by the user.
  • CancelResourceReserve RPC is sent to the raylet.
  • The CancelResourceReserve handler first tries to cancel any lease requests in the local task manager that need the PG resource AND is WAITING_FOR_WORKER. In this case there is none of them.
  • The worker that runs the first actor is forcibly killed by DestroyWorker which calls DisconnectClient. DisconnectClient first releases the PG resource used by the first actor since it's killed (PG_CPU_RESOURCE: [1/1]) and it calls ScheduleAndDispatchTasks which unblocks the second actor and the just released PG resource is claimed by the second actor immediately
    bool schedulable =
    (PG_CPU_RESOURCE: [0/1])
  • Then we try to return the PG resource
    RAY_CHECK_OK(placement_group_resource_manager_->ReturnBundle(bundle_spec));
    which expects the PG resource is completely free (i.e. available == total) but it's not the case since it's now used by the second actor (i.e. available is 0) and causes the check failure.

The fix is that when the PG is removed, we should cancel the actor 2 lease request as well. So by the time we DestroyWorker of actor 1, actor 2 lease request is already cancelled and removed from the local task manager dispatch queue so that it won't have chance to acquire the PG resource released by the first actor.

This is the minimal fix for #51124 and I have a follow-up #52751 to make the relevant code cleaner and add c++ unit tests after #53120 is merged.

Related issue number

Closes #51124

Checks

@jjyao
jjyao requested a review from MengjinYan May 21, 2025 06:17
@jjyao jjyao added the go add ONLY when ready to merge, run all tests label May 21, 2025

@MengjinYan MengjinYan 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.

Thanks!

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

Labels

community-backlog go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Core] RayCheck failed: placement_group_resource_manager_->ReturnBundle(bundle_spec) Status not OK

3 participants