Fix ThreadSanitizer data races between bundle processing and async background writer closing in FileBasedSink and WriteFiles - #39458
Conversation
…ckground writer closing in FileBasedSink and WriteFiles
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
|
Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment |
|
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). |
|
R: @sjvanrossum |
|
Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment |
|
If I understand correctly, Alternatively, attempt a CAS on |
Fixes ThreadSanitizer data race errors reported during asynchronous writer closing in
WriteFilesandFileBasedSink.Unsynchronized Cross-Thread Lifecycle Access:
In
WriteFiles.WriteShardsIntoTempFilesFn, aFileBasedSink.Writeris 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 aForkJoinPoolthread. Because plain Java fields (id,destination,outputFile,channel) lack release-acquire barriers across threads, ThreadSanitizer flags reads insidewriter.close()as racing with writes insidewriter.open().Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
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, commentfixes #<ISSUE NUMBER>instead.CHANGES.mdwith noteworthy changes.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)
See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.