Skip to content

Wake pending retries when capacity is released - #4293

Open
Hasnaathussain wants to merge 1 commit into
dstackai:masterfrom
Hasnaathussain:issue_4246_capacity_release_priority
Open

Hasnaathussain wants to merge 1 commit into
dstackai:masterfrom
Hasnaathussain:issue_4246_capacity_release_priority

Conversation

@Hasnaathussain

Copy link
Copy Markdown

Fixes #4246

When a capacity-starved run returns to PENDING, the retry delay grows to a repeated 10-minute rung. A newer lower-priority run can then reach the submitted-job queue first and take a block that a longer-waiting run could use.

This change marks pending retry runs for one immediate pass when a real instance releases a job, then wakes RunPipeline. The pending worker consumes the existing one-pass signal and clears it after submitting or skipping the run. Normal exponential backoff remains unchanged when no capacity-release signal is present, and the pipeline's existing queue and worker limits still bound concurrent processing.

The regression coverage checks the delayed retry path, the fetcher's one-pass flag handoff, and the real-instance unassignment wake-up. Placeholder deletion does not emit the unassignment event and does not trigger this path.

Validation:

  • uv run ruff check
  • uv run ruff format --check
  • uv run pre-commit run --files src/dstack/_internal/server/background/pipeline_tasks/jobs_terminating.py src/dstack/_internal/server/background/pipeline_tasks/runs/__init__.py src/dstack/_internal/server/background/pipeline_tasks/runs/pending.py src/tests/_internal/server/background/pipeline_tasks/test_runs/test_pending.py src/tests/_internal/server/background/pipeline_tasks/test_runs/test_pipeline.py src/tests/_internal/server/background/pipeline_tasks/test_terminating_jobs.py
  • npx --yes pyright --pythonpath .venv\\Scripts\\python.exe
  • uv run pytest src/tests/_internal/server/background/pipeline_tasks/test_runs/test_pending.py -q under WSL (9 passed, 9 skipped)
  • uv run pytest src/tests/_internal/server/background/pipeline_tasks/test_runs/test_pipeline.py -q under WSL (3 passed, 3 skipped)
  • uv run pytest src/tests/_internal/server/background/pipeline_tasks/test_terminating_jobs.py -q under WSL (27 passed, 27 skipped)
  • Linux SQLite variants: 39 passed; PostgreSQL variants were skipped locally because Docker is unavailable

Signed-off-by: Hasnaat Hussain <hasnaat.hussain.2@gmail.com>
Copilot AI lite review requested due to automatic review settings September 16, 2026 02:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: no-capacity retry backoff is anti-correlated with wait time, so priority inverts among schedulable runs

2 participants