fix(driver): force JVM exit to prevent hanging RayJobs#481
Draft
my-vegetable-has-exploded wants to merge 2 commits into
Draft
fix(driver): force JVM exit to prevent hanging RayJobs#481my-vegetable-has-exploded wants to merge 2 commits into
my-vegetable-has-exploded wants to merge 2 commits into
Conversation
added 2 commits
May 15, 2026 10:49
- Add DriverExitState: thread-safe state machine tracking FINISHED/FAILED/KILLED with exit codes and diagnostics - Add DriverAppMasterReporter: reports terminal state to RayAppMaster via FinishApplication RPC, idempotent with CAS-based once-only reporting - Replace UnregisterApplication with FinishApplication containing state/exitCode/diagnostics - Add ApplicationInfo.finish() method and exitCode/diagnostics fields - Add RayAppMaster.finishApplication() and RayAppMasterUtils Java accessor - Track driver exit in SparkSubmit: wrap main with try/catch, report state on exit - Wire DriverAppMasterReporter.bind/bindMasterHandle in scheduler backend - Handle KILLED state in RayCoarseGrainedSchedulerBackend.stop() - Make shuffle service actors named and idempotent - Remove obsolete TestRayCoarseGrainedSchedulerBackend tests Signed-off-by: epsilonwang <epsilonwang@didiglobal.com>
- Add JvmExitGuard: daemon thread that forces System.exit() after a configurable timeout (default 300s) when the driver reaches terminal state, preventing RayJobs from hanging due to non-daemon threads - Replace hardcoded exit codes in DriverExitState with JvmExitGuard constants (EXIT_SUCCESS=0, EXIT_APP_FAILED=1, EXIT_KILLED=143) - Update ApplicationInfo to use JvmExitGuard.EXIT_SUCCESS - Add JvmExitGuard.arm() call in finalizeDriverTermination and KILLED path - Stop SparkContext in finally block for ray:// master URLs - Add RAYDP_JVM_EXIT_TIMEOUT env var support in raydp-submit Signed-off-by: epsilonwang <epsilonwang@didiglobal.com>
Contributor
Author
|
wait for #480 |
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.
Motivation
In Spark on Ray scenarios, the driver logic may finish but the JVM cannot exit naturally because non-daemon threads (e.g. Hudi Embedded Timeline Server, connection pools, etc.) keep it alive. KubeRay RayJob relies on the entrypoint process exiting to determine job completion, so this causes RayJobs to stay in
RUNNINGstate indefinitely.Approach
JvmExitGuard— a singleton that, when armed, starts a daemon countdown thread. If the JVM hasn't exited within the configured timeout, it forcibly callsSystem.exit(). IfSystem.exit()throwsIllegalStateException(JVM already in its shutdown sequence), it falls back toRuntime.getRuntime().halt()which bypasses all shutdown hooks and terminates immediately.Unified exit code constants —
EXIT_SUCCESS=0,EXIT_APP_FAILED=1,EXIT_KILLED=143. Replace all hardcoded exit codes inDriverExitStateandApplicationInfowith these constants.Arm points:
finalizeDriverTermination()— called on normal exit, failure, and exit function redirectstop(KILLED)path inRayCoarseGrainedSchedulerBackendraydp-submitintegration — forwardRAYDP_JVM_EXIT_TIMEOUTenvironment variable as-Draydp.jvm.exit.timeoutJVM property.