Skip to content

[SPARK-58536] Fix getDefaultFinalStatus to return SUCCEEDED in cluster mode - #57736

Open
Lobo2008 wants to merge 1 commit into
apache:masterfrom
Lobo2008:fix-am-default-status
Open

[SPARK-58536] Fix getDefaultFinalStatus to return SUCCEEDED in cluster mode#57736
Lobo2008 wants to merge 1 commit into
apache:masterfrom
Lobo2008:fix-am-default-status

Conversation

@Lobo2008

@Lobo2008 Lobo2008 commented Aug 4, 2026

Copy link
Copy Markdown

What changes were proposed in this pull request?

Fix getDefaultFinalStatus() to return FinalApplicationStatus.SUCCEEDED
for cluster mode, matching its documentation.

Why are the changes needed?

The current implementation returns FAILED for cluster mode, while the
docstring says it should return SUCCEEDED. The docstring correctly
describes the intent: when a user's application calls System.exit(0),
the shutdown hook fires before finish(SUCCEEDED) can be reached. The
default status should be SUCCEEDED in this case, as the application
completed normally.

This is safe because genuinely failed applications call finish(FAILED)
explicitly, which sets finished = true, causing the shutdown hook to
skip the default status entirely.

Does this PR introduce any user-facing change?

Yes — cluster mode applications that exit via
System.exit(0) will now report SUCCEEDED to YARN RM instead of FAILED.

How was this patch tested?

Manual testing with Spark 4.1.1 in cluster mode on Hadoop 3.2 RM
with Hadoop 3.4.2 client. Verified that YARN RM shows SUCCEEDED
after the fix.

…r mode

The docstring for getDefaultFinalStatus() says it should return SUCCEEDED
in cluster mode 'to handle if the user calls System.exit from the application
code', but the implementation returns FAILED. This causes applications
that exit normally via System.exit(0) in cluster mode to report FAILED
to YARN RM when the shutdown hook fires before finish(SUCCEEDED) is reached.

Fix the implementation to match the documented behavior.
@Lobo2008 Lobo2008 changed the title [SPARK-58536] Fix getDefaultFinalStatus to return SUCCEEDED in cluste… [SPARK-58536] Fix getDefaultFinalStatus to return SUCCEEDED in cluster mode Aug 4, 2026
final def getDefaultFinalStatus(): FinalApplicationStatus = {
if (isClusterMode) {
FinalApplicationStatus.FAILED
FinalApplicationStatus.SUCCEEDED

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This inverts a FAIL-SAFE default, and the justification rests on a STALE docstring rather than the code's intent. The FAILED default was set deliberately in SPARK-38270; the docstring mentioning SUCCEEDED predates that change and was not updated. The real defect is the comment, not the code. This PR resolves the mismatch in the wrong direction.

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.

2 participants