Skip to content

[examples] Atomically publish subprocess executables - #39621

Open
bvolpato wants to merge 1 commit into
apache:masterfrom
bvolpato:bvolpato/fix-subprocess-etxtbsy-flake
Open

[examples] Atomically publish subprocess executables#39621
bvolpato wants to merge 1 commit into
apache:masterfrom
bvolpato:bvolpato/fix-subprocess-etxtbsy-flake

Conversation

@bvolpato

@bvolpato bvolpato commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

ExampleEchoPipelineTest intermittently fails on Linux while launching a freshly copied shell executable:

java.io.IOException: Cannot run program ".../test-EchoAgain....sh":
Exec failed, error: 26 (Text file busy)

This occurred twice in scheduled Java precommit runs, including https://github.com/apache/beam/actions/runs/30802709511.

FileUtils.copyFileFromGCSToWorker currently 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 ProcessBuilder failures 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

  • FileUtilsTest and ExampleEchoPipelineTest: 10 consecutive passes
  • ./gradlew :examples:java:spotlessCheck :examples:java:checkstyleMain :examples:java:checkstyleTest --no-build-cache
  • Full :examples:java:test attempted: 69 tests passed; unrelated KafkaToPubsubE2ETest class setup could not start because Docker is unavailable locally

@bvolpato
bvolpato force-pushed the bvolpato/fix-subprocess-etxtbsy-flake branch 2 times, most recently from c6c365a to 4f984bb Compare August 5, 2026 03:29
@bvolpato
bvolpato force-pushed the bvolpato/fix-subprocess-etxtbsy-flake branch from 4f984bb to e67c2e3 Compare August 5, 2026 23:04
@bvolpato
bvolpato marked this pull request as ready for review August 5, 2026 23:10
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @chamikaramj for label java.

Note: If you would like to opt out of this review, comment assign to next reviewer.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

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