fix: fix bind port failed on spark yarn environment - #2233
Closed
coddderX wants to merge 3 commits into
Closed
Conversation
Mark Hamilton (mhamilton723)
approved these changes
Jun 12, 2024
Contributor
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2233 +/- ##
==========================================
- Coverage 84.43% 84.43% -0.01%
==========================================
Files 327 327
Lines 16773 16771 -2
Branches 1511 1530 +19
==========================================
- Hits 14162 14160 -2
Misses 2611 2611 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
| try { | ||
| taskCtx.networkTopologyInfo.localSocket.close() | ||
| } catch { | ||
| case e: Exception => log.warn("close local bind port socket failed ") |
Contributor
There was a problem hiding this comment.
this looks like its a bit generic of a error, can we make it more specific so we dont catch other errors?
Contributor
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Rana Singh (ranadeepsingh)
added a commit
to ranadeepsingh/SynapseML
that referenced
this pull request
Aug 1, 2026
## Summary Keep each JVM socket reservation alive through topology exchange and data preparation, then release it immediately before native LightGBM network initialization. Clean up training, helper, and failure paths and add focused contention and cleanup regressions. ## Prompting Intent Recreate the still-valid fix from ancient PR microsoft#2233 on current master, resolve issue microsoft#2230 without broad exception handling or silent fallback, preserve public API compatibility, and validate port competition and cleanup using TDD. ## Linked Sources - Original pull request: microsoft#2233 - Original issue: microsoft#2230 - Unresolved review comment: microsoft#2233 (comment) ## Rationale Store the reservation as transient internal state on the existing three-field topology type so callers remain source compatible. Advance to another port only for BindException; propagate other failures. Release at the unavoidable JVM-to-native handoff because the Java socket cannot be transferred to LightGBM, with final cleanup covering initialization, preparation, helper, and failure paths. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Rana Singh (ranadeepsingh)
added a commit
to ranadeepsingh/SynapseML
that referenced
this pull request
Aug 1, 2026
## Summary Keep each JVM socket reservation alive through topology exchange and data preparation, then release it immediately before native LightGBM network initialization. Clean up training, helper, and failure paths and add focused contention and cleanup regressions. ## Prompting Intent Recreate the still-valid fix from ancient PR microsoft#2233 on current master, resolve issue microsoft#2230 without broad exception handling or silent fallback, preserve public API compatibility, and validate port competition and cleanup using TDD. ## Linked Sources - Original pull request: microsoft#2233 - Original issue: microsoft#2230 - Unresolved review comment: microsoft#2233 (comment) ## Rationale Store the reservation as transient internal state on the existing three-field topology type so callers remain source compatible. Advance to another port only for BindException; propagate other failures. Release at the unavoidable JVM-to-native handoff because the Java socket cannot be transferred to LightGBM, with final cleanup covering initialization, preparation, helper, and failure paths. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Rana Singh (ranadeepsingh)
added a commit
to ranadeepsingh/SynapseML
that referenced
this pull request
Aug 1, 2026
## Summary Preserve primary task failures when port-reservation cleanup also fails, retry socket closure while the reservation remains reachable, and hold the exact advertised port during native network-init backoff. ## Prompting Intent Resolve the two independent medium findings on PR microsoft#2595: prevent cleanup from masking primary failures or losing open sockets, and eliminate the native-init retry race without broad fallback catches. Add focused suppression, cleanup-retry, exact-port backoff, and contention regressions. ## Linked Sources - Replacement pull request: microsoft#2595 - Original pull request: microsoft#2233 - Original issue: microsoft#2230 - Original unresolved review: microsoft#2233 (comment) ## Rationale Retry only IOException failures declared by Socket.close, while a tightly scoped Throwable-preservation helper immediately rethrows the protected operation and records cleanup failures as suppressed. Re-reserve only the already-advertised port between native attempts; if contention wins, fail safely with the native error primary so Spark can renegotiate instead of retrying an unreserved or different port. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Rana Singh (ranadeepsingh)
added a commit
to ranadeepsingh/SynapseML
that referenced
this pull request
Aug 1, 2026
## Summary Carry the preceding native-init failure through backoff-reservation release, suppress close failures onto it, and continue the retry when the socket ultimately closes. ## Prompting Intent Resolve the remaining medium review finding on PR microsoft#2595 without weakening cleanup reporting: a first close may fail while the immediate retry succeeds, so the native retry must proceed without replacing its original failure. ## Linked Sources - Replacement pull request: microsoft#2595 - Original pull request: microsoft#2233 - Original issue: microsoft#2230 ## Rationale Use an explicit internal overload to preserve the existing test seam and pass the prior native failure only across the recursive handoff. Continue only after synchronized reservation state confirms the socket closed; otherwise throw the native failure with aggregated close errors suppressed so no unsafe bind occurs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Rana Singh (ranadeepsingh)
added a commit
to ranadeepsingh/SynapseML
that referenced
this pull request
Aug 7, 2026
## Summary Keep each JVM socket reservation alive through topology exchange and data preparation, then release it immediately before native LightGBM network initialization. Clean up training, helper, and failure paths and add focused contention and cleanup regressions. ## Prompting Intent Recreate the still-valid fix from ancient PR microsoft#2233 on current master, resolve issue microsoft#2230 without broad exception handling or silent fallback, preserve public API compatibility, and validate port competition and cleanup using TDD. ## Linked Sources - Original pull request: microsoft#2233 - Original issue: microsoft#2230 - Unresolved review comment: microsoft#2233 (comment) ## Rationale Store the reservation as transient internal state on the existing three-field topology type so callers remain source compatible. Advance to another port only for BindException; propagate other failures. Release at the unavoidable JVM-to-native handoff because the Java socket cannot be transferred to LightGBM, with final cleanup covering initialization, preparation, helper, and failure paths. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Rana Singh (ranadeepsingh)
added a commit
to ranadeepsingh/SynapseML
that referenced
this pull request
Aug 7, 2026
## Summary Preserve primary task failures when port-reservation cleanup also fails, retry socket closure while the reservation remains reachable, and hold the exact advertised port during native network-init backoff. ## Prompting Intent Resolve the two independent medium findings on PR microsoft#2595: prevent cleanup from masking primary failures or losing open sockets, and eliminate the native-init retry race without broad fallback catches. Add focused suppression, cleanup-retry, exact-port backoff, and contention regressions. ## Linked Sources - Replacement pull request: microsoft#2595 - Original pull request: microsoft#2233 - Original issue: microsoft#2230 - Original unresolved review: microsoft#2233 (comment) ## Rationale Retry only IOException failures declared by Socket.close, while a tightly scoped Throwable-preservation helper immediately rethrows the protected operation and records cleanup failures as suppressed. Re-reserve only the already-advertised port between native attempts; if contention wins, fail safely with the native error primary so Spark can renegotiate instead of retrying an unreserved or different port. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Rana Singh (ranadeepsingh)
added a commit
to ranadeepsingh/SynapseML
that referenced
this pull request
Aug 7, 2026
## Summary Carry the preceding native-init failure through backoff-reservation release, suppress close failures onto it, and continue the retry when the socket ultimately closes. ## Prompting Intent Resolve the remaining medium review finding on PR microsoft#2595 without weakening cleanup reporting: a first close may fail while the immediate retry succeeds, so the native retry must proceed without replacing its original failure. ## Linked Sources - Replacement pull request: microsoft#2595 - Original pull request: microsoft#2233 - Original issue: microsoft#2230 ## Rationale Use an explicit internal overload to preserve the existing test seam and pass the prior native failure only across the recursive handoff. Continue only after synchronized reservation state confirms the socket closed; otherwise throw the native failure with aggregated close errors suppressed so no unsafe bind occurs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Collaborator
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.
Related Issues/PRs
Close #2230
What changes are proposed in this pull request?
When training in a yarn Spark environment, sometimes it may encounter port binding failure. This is because multiple Spark jobs might be running on the same machine, but the port binding does not occur simultaneously. For example, at 10:01:00, task 1 of JobA finds that port 10001 is available. Then all tasks in JobA find the port and close immediately, not until 10:03:00 does lightgbm bind to port 10001. At the same time, task 1 of Spark JobB finds port 1001 available at 10:02:00, then all tasks in JobB find the port and close immediately. However, until 10:04:00, lightgbm attempts to bind to port 10001, but the binding fails due to port conflict.
like issuse 2230
How is this patch tested?
Does this PR change any dependencies?
Does this PR add a new feature? If so, have you added samples on website?
website/docs/documentationfolder.Make sure you choose the correct class
estimators/transformersand namespace.DocTablepoints to correct API link.yarn run startto make sure the website renders correctly.<!--pytest-codeblocks:cont-->before each python code blocks to enable auto-tests for python samples.WebsiteSamplesTestsjob pass in the pipeline.