Skip to content

Fix ThreadSanitizer data races between bundle processing and async background writer closing in FileBasedSink and WriteFiles#39458

Open
stankiewicz wants to merge 1 commit into
apache:masterfrom
stankiewicz:tsan_filebasedsink
Open

Fix ThreadSanitizer data races between bundle processing and async background writer closing in FileBasedSink and WriteFiles#39458
stankiewicz wants to merge 1 commit into
apache:masterfrom
stankiewicz:tsan_filebasedsink

Conversation

@stankiewicz

Copy link
Copy Markdown
Contributor

Fixes ThreadSanitizer data race errors reported during asynchronous writer closing in WriteFiles and FileBasedSink.

Unsynchronized Cross-Thread Lifecycle Access:
In WriteFiles.WriteShardsIntoTempFilesFn, a FileBasedSink.Writer is instantiated, opened (writer.open()), and written to on the bundle processing thread. Once bundle processing completes, closeWriterInBackground(writer) submits asynchronous background tasks (MoreFutures.runAsync) to close each writer on a ForkJoinPool thread. Because plain Java fields (id, destination, outputFile, channel) lack release-acquire barriers across threads, ThreadSanitizer flags reads inside writer.close() as racing with writes inside writer.open().


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Mention the appropriate issue in your description (for example: addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment fixes #<ISSUE NUMBER> instead.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.

…ckground writer closing in FileBasedSink and WriteFiles
@github-actions github-actions Bot added the java label Jul 23, 2026
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@github-actions

Copy link
Copy Markdown
Contributor

Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment assign set of reviewers

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant