[Serve] Fix gang scheduling PG leak when deployment actors are starting#62469
Merged
abrarsheikh merged 5 commits intoApr 11, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces a serve_instance fixture in test_deployment_actors.py to restart the Serve controller between tests, preventing performance degradation caused by accumulated state. Feedback suggests replacing delete_all_apps() with serve.shutdown() in the fixture teardown to more reliably ensure a clean state if the controller becomes unresponsive.
jeffreywang88
approved these changes
Apr 9, 2026
Contributor
|
signing off for the gang scheduling pieces |
abrarsheikh
reviewed
Apr 9, 2026
When a deployment uses both gang scheduling and deployment actors, _reserve_gang_placement_groups() creates placement groups every control loop tick (~100ms) while deployment actors are starting. But scale_deployment_replicas() defers replica creation until actors are ready, leaving the PGs orphaned. After ~2 seconds all cluster resources are consumed by phantom PGs and replicas can never be scheduled. Fix: skip PG reservation in _reserve_gang_placement_groups() when deployment actors are configured but not yet ready, matching the precondition in scale_deployment_replicas(). Before: test_gang_scheduling_with_deployment_actors hangs for 180s After: passes in 34s Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: harshit <harshit@anyscale.com>
dc92046 to
a184afa
Compare
abrarsheikh
approved these changes
Apr 9, 2026
HLDKNotFound
pushed a commit
to chichic21039/ray
that referenced
this pull request
Apr 22, 2026
…ng (ray-project#62469) ## Summary Fix a placement group leak in gang scheduling when deployment actors are configured. ### Root cause When a deployment uses both gang scheduling and deployment actors, `_reserve_gang_placement_groups()` creates placement groups every control loop tick (~100ms) while deployment actors are starting. But `scale_deployment_replicas()` defers replica creation until actors are ready, leaving the PGs orphaned. After ~2 seconds, all cluster resources are consumed by phantom PGs and replicas can never be scheduled — deadlock. **The sequence on every tick while deployment actors are starting:** 1. `_reserve_gang_placement_groups()`: replica delta > 0 → creates PG (reserves 2 CPUs) 2. `scale_deployment_replicas()`: deployment actors not ready → returns empty upscale → PG unused 3. Next tick: creates another PG (delta still > 0), still empty upscale 4. After ~18 ticks (~2s): all 36 CPUs consumed by orphaned PGs, zero resources left ### Fix Skip PG reservation in `_reserve_gang_placement_groups()` when deployment actors are configured but not yet ready, matching the precondition already in `scale_deployment_replicas()`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: harshit <harshit@anyscale.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Lucas61000
pushed a commit
to Lucas61000/ray
that referenced
this pull request
May 15, 2026
…ng (ray-project#62469) ## Summary Fix a placement group leak in gang scheduling when deployment actors are configured. ### Root cause When a deployment uses both gang scheduling and deployment actors, `_reserve_gang_placement_groups()` creates placement groups every control loop tick (~100ms) while deployment actors are starting. But `scale_deployment_replicas()` defers replica creation until actors are ready, leaving the PGs orphaned. After ~2 seconds, all cluster resources are consumed by phantom PGs and replicas can never be scheduled — deadlock. **The sequence on every tick while deployment actors are starting:** 1. `_reserve_gang_placement_groups()`: replica delta > 0 → creates PG (reserves 2 CPUs) 2. `scale_deployment_replicas()`: deployment actors not ready → returns empty upscale → PG unused 3. Next tick: creates another PG (delta still > 0), still empty upscale 4. After ~18 ticks (~2s): all 36 CPUs consumed by orphaned PGs, zero resources left ### Fix Skip PG reservation in `_reserve_gang_placement_groups()` when deployment actors are configured but not yet ready, matching the precondition already in `scale_deployment_replicas()`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: harshit <harshit@anyscale.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
Fix a placement group leak in gang scheduling when deployment actors are configured.
Root cause
When a deployment uses both gang scheduling and deployment actors,
_reserve_gang_placement_groups()creates placement groups every control loop tick (~100ms) while deployment actors are starting. Butscale_deployment_replicas()defers replica creation until actors are ready, leaving the PGs orphaned. After ~2 seconds, all cluster resources are consumed by phantom PGs and replicas can never be scheduled — deadlock.The sequence on every tick while deployment actors are starting:
_reserve_gang_placement_groups(): replica delta > 0 → creates PG (reserves 2 CPUs)scale_deployment_replicas(): deployment actors not ready → returns empty upscale → PG unusedFix
Skip PG reservation in
_reserve_gang_placement_groups()when deployment actors are configured but not yet ready, matching the precondition already inscale_deployment_replicas().🤖 Generated with Claude Code