Skip to content

[CELEBORN-2591] Avoid leaking DataPusher threads on Spark sort writer initialization failure - #3996

Open
zaynt4606 wants to merge 1 commit into
apache:mainfrom
zaynt4606:fix-sort-pusher-initialization-cleanup
Open

zaynt4606 wants to merge 1 commit into
apache:mainfrom
zaynt4606:fix-sort-pusher-initialization-cleanup

Conversation

@zaynt4606

@zaynt4606 zaynt4606 commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Allocate the initial pointer array before starting DataPusher. If pusher initialization fails after the array allocation, release the array and return any borrowed push task queue.

JIRA: https://issues.apache.org/jira/browse/CELEBORN-2591

Why are the changes needed?

A SORT writer starts DataPusher before allocating its initial pointer array. If Spark cannot grant the full allocation, the constructor throws and does not return a writer that can close the pusher.

On Spark 3.5.9, two SORT pushers using the default 64 MiB threshold shared 12 MiB of managed off-heap memory. The first allocation used 8 MiB. The second received 4 MiB and threw SparkOutOfMemoryError, leaving its DataPusher thread alive. Releasing the first pusher allowed a subsequent construction to succeed. A local Spark shuffle with 4 MiB of off-heap execution memory reproduced four leftover threads after four failed task attempts.

Does this PR resolve a correctness bug?

  • Yes

Does this PR introduce any user-facing change?

  • Yes

A SORT writer whose pointer allocation fails no longer leaves an idle background push thread.

How was this patch tested?

SortBasedPusherSuiteJ and ShuffleInMemorySorterSuiteJ passed.

dev/reformat
build/mvn -B -ntp -Pspark-3.5 -pl client-spark/common -am test -Dtest=SortBasedPusherSuiteJ,ShuffleInMemorySorterSuiteJ -DwildcardSuites=org.apache.celeborn.NoMatchingScalaSuite -Dsurefire.failIfNoSpecifiedTests=false -DfailIfNoTests=false

… initialization failure

Co-Authored-By: Codex <noreply@openai.com>
AI-Model: gpt-6
AI-Contributed/Feature: 31/31
AI-Contributed/UT: 47/47
@github-actions github-actions Bot added module:client module:spark correctness Correctness bugfix and removed correctness Correctness bugfix labels Nov 20, 2026

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant