Skip to content

[core] Job stuck in PENDING forever when HTTP request is cancelled during submission #62766

Open

Description

@Myasuka

What happened + What you expected to happen

When a job submission HTTP request is cancelled (e.g., client timeout, connection reset) after the job has been written to GCS as PENDING but before the supervisor actor is created, the job remains in PENDING status forever. No supervisor actor is spawned, and the job is never cleaned up — it becomes an orphan.

Expected: The job should transition to FAILED with a clear error message.

How to reproduce
This bug requires a specific timing sequence:

  1. Client submits a job via POST /api/jobs/
  2. The dashboard agent handler writes the job to GCS as PENDING (via put_info(overwrite=False))
  3. Before the supervisor actor is created, asyncio.CancelledError is raised — this happens when aiohttp cancels the handler coroutine because the HTTP client disconnected
  4. The CancelledError propagates through submit_job uncaught, leaving the job permanently PENDING

Versions / Dependencies

ray-2.47
python-3.9

Reproduction script

In job_manager.py submit_job(), after put_info(submission_id, job_info, overwrite=False) writes PENDING to GCS, there are multiple await points before the supervisor actor is created:

put_info(PENDING)          ← job exists in GCS
    ↓
await _get_scheduling_strategy(...)    ← CancelledError can strike here
    ↓
supervisor_actor.options(...).remote(...)
    ↓
supervisor.run.remote(...)
    ↓
run_background_task(_monitor_job(...))  ← only now is the job "alive"
The existing error handler is:
except Exception as e:
    await self._job_info_client.put_status(submission_id, JobStatus.FAILED, ...)

asyncio.CancelledError inherits from BaseException, not Exception. So this handler does not catch it. The CancelledError propagates out, leaving an orphan PENDING entry in GCS.

Issue Severity

Medium: It is a significant difficulty but I can work around it.

Activity

  1. added
    bugSomething that is supposed to be working; but isn't
    triageNeeds triage (eg: priority, bug/not-bug, and owning component)
    on Apr 20, 2026
  2. Myasuka commented on Apr 20, 2026

    @Myasuka
    ContributorAuthor

    I'll prepare a bug fix for this problem.

  3. pardeep-singh commented on Oct 18, 2026

    @pardeep-singh
    Contributor

    I'd like to take this, since #62951 was closed as stale. Plan: in JobManager.submit_job, once the job has been written as PENDING, catch asyncio.CancelledError before the supervisor actor exists, mark the job FAILED with a message saying the submission was cancelled, and re-raise. I'll add a regression test in test_job_manager.py that cancels a submission at that point.

  4. removed
    triageNeeds triage (eg: priority, bug/not-bug, and owning component)
    on Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething that is supposed to be working; but isn'tcommunity-backlogcoreIssues that should be addressed in Ray Corestability

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions