Skip to content

Conversation

@ChuckLin2025
Copy link

What changes were proposed in this pull request?

  • Move createTaskRunner into try-catch block to handle construction failures
  • Add cleanup to remove TaskRunner from runningTasks if threadPool.execute throws
    Prevent potential memory leak by cleaning up TaskRunner when threadPool.execute fails

Why are the changes needed?

The createTaskRunner may throw an Exception.

Does this PR introduce any user-facing change?

No

How was this patch tested?

Added an unit test.

Was this patch authored or co-authored using generative AI tooling?

Generated-by: claude-4.5

Zequn Lin added 2 commits January 20, 2026 04:01
…on failure

- Move createTaskRunner into try-catch block to handle construction failures
- Add cleanup to remove TaskRunner from runningTasks if threadPool.execute throws
- Prevent potential memory leak by cleaning up TaskRunner when threadPool.execute fails
- Update test to use current TaskDescription API
- Use reflection to mock runningTasks.put to throw exception
- Tests cleanup logic when TaskRunner is created but fails to be added to runningTasks
- Verify exception is properly caught and reported to driver
@github-actions github-actions bot added the CORE label Jan 20, 2026
@github-actions
Copy link

github-actions bot commented Jan 20, 2026

JIRA Issue Information

=== Bug SPARK-55093 ===
Summary: Handle TaskRunner construction failures in launchTask
Assignee: None
Status: Open
Affected: ["4.1.1"]


This comment was automatically generated by GitHub Actions

@ChuckLin2025
Copy link
Author

@cloud-fan @Ngone51 What do you think about this PR ?

@ChuckLin2025 ChuckLin2025 changed the title 55093 [SPARK 55093] Handle TaskRunner construction failures in launchTask #1 Jan 20, 2026
@ChuckLin2025 ChuckLin2025 changed the title [SPARK 55093] Handle TaskRunner construction failures in launchTask #1 [SPARK 55093] Handle TaskRunner construction failures in launchTask Jan 20, 2026
Copy link
Member

@Ngone51 Ngone51 left a comment

Choose a reason for hiding this comment

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

LGTM

@Ngone51 Ngone51 changed the title [SPARK 55093] Handle TaskRunner construction failures in launchTask [SPARK 55093][CORE] Handle TaskRunner construction failures in launchTask Jan 20, 2026
@cloud-fan cloud-fan changed the title [SPARK 55093][CORE] Handle TaskRunner construction failures in launchTask [SPARK-55093][CORE] Handle TaskRunner construction failures in launchTask Jan 21, 2026
…ng mocked Executor fields

The test was failing because mocked Executor's val fields (runningTasks, threadPool,
conf, env, killMarks) were not initialized when using mock[Executor](CALLS_REAL_METHODS).
This caused NullPointerExceptions when the real launchTask method tried to access them.

Solution: Use reflection to manually set these val fields on the mocked Executor object
after creation, allowing the real launchTask method to execute properly and add tasks
to the runningTasks map.

Test now passes consistently in ~1.4 seconds.
@ChuckLin2025
Copy link
Author

ChuckLin2025 commented Jan 26, 2026

@Ngone51 Could you please take another look here ? I fix the test case "track allocated resources by taskId" in a new commit.

The test case didn't mock the killMarks and ran into a null Exception. It passed before this PR because we didn't handle the exception and run the cleanup job.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants