[examples] Atomically publish subprocess executables - #39621
Open
bvolpato wants to merge 1 commit into
Open
Conversation
bvolpato
force-pushed
the
bvolpato/fix-subprocess-etxtbsy-flake
branch
2 times, most recently
from
August 5, 2026 03:29
c6c365a to
4f984bb
Compare
bvolpato
force-pushed
the
bvolpato/fix-subprocess-etxtbsy-flake
branch
from
August 5, 2026 23:04
4f984bb to
e67c2e3
Compare
bvolpato
marked this pull request as ready for review
August 5, 2026 23:10
Contributor
|
Assigning reviewers: R: @chamikaramj for label java. Note: If you would like to opt out of this review, comment Available commands:
The PR bot will only process comments in the main thread (not review comments). |
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.
ExampleEchoPipelineTestintermittently fails on Linux while launching a freshly copied shell executable:This occurred twice in scheduled Java precommit runs, including https://github.com/apache/beam/actions/runs/30802709511.
FileUtils.copyFileFromGCSToWorkercurrently copies directly to the executable's final path. Its in-process lock does not protect separate classloaders or worker processes sharing that path, so another process can try to execute the destination while it is still open for writing.This change stages each executable in a temporary sibling file, makes the staged file executable, then atomically replaces the destination. Readers therefore see either the previous complete executable or the new complete executable. Launch retries are intentionally avoided so unrelated
ProcessBuilderfailures remain visible.Reproduction
A focused Linux regression test holds the previous destination inode open for writing while publishing its replacement, then launches the destination path. Before this change it fails deterministically with
error=26, Text file busy; after this change it succeeds.Testing
FileUtilsTestandExampleEchoPipelineTest: 10 consecutive passes./gradlew :examples:java:spotlessCheck :examples:java:checkstyleMain :examples:java:checkstyleTest --no-build-cache:examples:java:testattempted: 69 tests passed; unrelatedKafkaToPubsubE2ETestclass setup could not start because Docker is unavailable locally