Skip to content

[Jobs] Eagerly initialize JobManager on head startup - #65261

Open
zzchun wants to merge 2 commits into
ray-project:masterfrom
zzchun:fix/jobmanager-eager-recovery-2.56
Open

[Jobs] Eagerly initialize JobManager on head startup#65261
zzchun wants to merge 2 commits into
ray-project:masterfrom
zzchun:fix/jobmanager-eager-recovery-2.56

Conversation

@zzchun

@zzchun zzchun commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Eagerly initialize JobManager when the head Dashboard Agent starts so
non-terminal submission jobs are recovered without requiring a subsequent
Job API request.

Worker Dashboard Agents retain the existing lazy initialization behavior.

Problem

JobManager.__init__() schedules _recover_running_jobs(), but JobManager
is lazily constructed by Job API handlers. After the head Dashboard Agent
restarts, existing PENDING or RUNNING jobs may therefore remain
unmonitored until another Job API request arrives.

This can leave stale jobs indefinitely in a non-terminal state when their
JobSupervisor no longer exists.

Changes

  • Initialize JobManager during head JobAgent.run().
  • Keep worker Dashboard Agents unchanged.
  • Run ray.init() in an executor so Dashboard Agent startup does not block
    the asyncio event loop.
  • Serialize process-level Ray initialization to avoid races with Job API
    handlers.
  • Retry initialization with capped exponential backoff and jitter.
  • Add bounded

Related issues

Fixes #65037

Additional information

Optional: Add implementation details, API changes, usage examples, screenshots, etc.

@zzchun
zzchun requested a review from a team as a code owner August 6, 2026 16:43

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request introduces eager initialization of the JobManager on the head node within the JobAgent, along with a robust, budgeted retry mechanism for recovering running jobs. It also refactors the Ray connection initialization into a thread-safe helper (init_ray_connection) run within an executor. Feedback is provided to optimize the @init_ray_and_catch_exceptions decorator by checking if Ray is already initialized in the main thread, thereby avoiding the overhead of thread pool scheduling and lock acquisition on every HTTP request.

Comment thread python/ray/dashboard/optional_utils.py Outdated

@cursor cursor Bot 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.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit d219241. Configure here.

Comment thread python/ray/dashboard/modules/job/job_manager.py
@ray-gardener ray-gardener Bot added core Issues that should be addressed in Ray Core community-contribution Contributed by the community labels Aug 7, 2026
zzchun added 2 commits August 7, 2026 15:24
Signed-off-by: will <zzchun8@gmail.com>
Signed-off-by: will <zzchun8@gmail.com>
@zzchun
zzchun force-pushed the fix/jobmanager-eager-recovery-2.56 branch from d219241 to a0d92d9 Compare August 7, 2026 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Contributed by the community core Issues that should be addressed in Ray Core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Jobs] JobManager recovery is not triggered after the head Dashboard Agent restarts

1 participant