Fix spark download deadlock#1475
Merged
wisechengyi merged 1 commit intomasterpolynote/polynote:masterfrom Nov 7, 2025
Merged
Conversation
Collaborator
Author
|
Additional testing: #1477 |
Collaborator
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
This was referenced Nov 5, 2025
Merged
Merged
Merged
Merged
jonathanindig
approved these changes
Nov 7, 2025
Collaborator
jonathanindig
left a comment
There was a problem hiding this comment.
LGTM thanks for tackling this!
There was a problem hiding this comment.
Copilot wasn't able to review any files in this pull request.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
wisechengyi
added a commit
that referenced
this pull request
Nov 7, 2025
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.
Problem
Race condition in Spark distribution download: The test setup lock file mechanism in
build.sbthad several critical issues:deleteOnExit()was unreliable in forked JVM processesThis resulted in CI failures like:
Solution
Improved lock file mechanism with robust cleanup
1. Early exit optimization:
destDirexists before any lock operations to avoid unnecessary locking2. Atomic lock acquisition:
createNewFile()which is atomic on most filesystems3. Smarter wait logic:
lockFile.exists()AND!destDir.exists()in the wait loop4. Stale lock detection and recovery:
destDirstill doesn't exist, assume stale lock5. Guaranteed lock cleanup:
finallyblock to ensure cleanup even on exceptions6. Version-specific lock files:
spark_3.1.2_scala_2.12_test_setup_is_running.lock7. Double-check pattern:
destDiragain to handle race conditions where another process completed between checksBenefits