You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by "jrmccluskey (via GitHub)" <gi...@apache.org> on 2025/07/31 19:48:29 UTC
[PR] Fix race condition in FnApiDoFnRunner.java [beam]
jrmccluskey opened a new pull request, #35757:
URL: https://github.com/apache/beam/pull/35757
Slide the construction and returned split into the synchronized block in trySplitForElementAndRestriction
------------------------
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](https://www.apache.org/licenses/icla.pdf).
See the [Contributor Guide](https://beam.apache.org/contribute) for more tips on [how to make review process smoother](https://github.com/apache/beam/blob/master/CONTRIBUTING.md#make-the-reviewers-job-easier).
To check the build health, please visit [https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md](https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md)
GitHub Actions Tests Status (on master branch)
------------------------------------------------------------------------------------------------
[](https://github.com/apache/beam/actions?query=workflow%3A%22Build+python+source+distribution+and+wheels%22+branch%3Amaster+event%3Aschedule)
[](https://github.com/apache/beam/actions?query=workflow%3A%22Python+Tests%22+branch%3Amaster+event%3Aschedule)
[](https://github.com/apache/beam/actions?query=workflow%3A%22Java+Tests%22+branch%3Amaster+event%3Aschedule)
[](https://github.com/apache/beam/actions?query=workflow%3A%22Go+tests%22+branch%3Amaster+event%3Aschedule)
See [CI.md](https://github.com/apache/beam/blob/master/CI.md) for more information about GitHub Actions CI or the [workflows README](https://github.com/apache/beam/blob/master/.github/workflows/README.md) to see a list of phrases to trigger workflows.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix race condition in FnApiDoFnRunner.java [beam]
Posted by "jrmccluskey (via GitHub)" <gi...@apache.org>.
jrmccluskey commented on PR #35757:
URL: https://github.com/apache/beam/pull/35757#issuecomment-3179364496
R: @Abacn
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix race condition in FnApiDoFnRunner.java [beam]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #35757:
URL: https://github.com/apache/beam/pull/35757#issuecomment-3179368172
Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment `assign set of reviewers`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix race condition in FnApiDoFnRunner.java [beam]
Posted by "Abacn (via GitHub)" <gi...@apache.org>.
Abacn commented on code in PR #35757:
URL: https://github.com/apache/beam/pull/35757#discussion_r2270079275
##########
sdks/java/harness/src/main/java/org/apache/beam/fn/harness/FnApiDoFnRunner.java:
##########
@@ -1180,18 +1180,18 @@ private HandlesSplits.SplitResult trySplitForElementAndRestriction(
splitResult.getWindowSplit(),
PTransformTranslation.SPLITTABLE_PROCESS_SIZED_ELEMENTS_AND_RESTRICTIONS_URN
+ "/GetSize");
+ Coder fullInputCoder = WindowedValues.getFullCoder(inputCoder, windowCoder);
+ return constructSplitResult(
+ windowedSplitResult,
+ null,
+ fullInputCoder,
+ initialWatermark,
+ watermarkAndState,
+ pTransformId,
+ mainInputId,
+ pTransform.getOutputsMap().keySet(),
+ resumeDelay);
}
Review Comment:
split shouldn't be frequent. Close for now.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix race condition in FnApiDoFnRunner.java [beam]
Posted by "gemini-code-assist[bot] (via GitHub)" <gi...@apache.org>.
gemini-code-assist[bot] commented on code in PR #35757:
URL: https://github.com/apache/beam/pull/35757#discussion_r2246251721
##########
sdks/java/harness/src/main/java/org/apache/beam/fn/harness/FnApiDoFnRunner.java:
##########
@@ -1180,18 +1180,18 @@ private HandlesSplits.SplitResult trySplitForElementAndRestriction(
splitResult.getWindowSplit(),
PTransformTranslation.SPLITTABLE_PROCESS_SIZED_ELEMENTS_AND_RESTRICTIONS_URN
+ "/GetSize");
+ Coder fullInputCoder = WindowedValues.getFullCoder(inputCoder, windowCoder);
+ return constructSplitResult(
+ windowedSplitResult,
+ null,
+ fullInputCoder,
+ initialWatermark,
+ watermarkAndState,
+ pTransformId,
+ mainInputId,
+ pTransform.getOutputsMap().keySet(),
+ resumeDelay);
}
Review Comment:

Moving the `Coder fullInputCoder = WindowedValues.getFullCoder(inputCoder, windowCoder);` and `constructSplitResult` calls inside the synchronized block correctly fixes the race condition on `initialWatermark`. However, this increases the time the lock is held, as `constructSplitResult` performs encoding which can be CPU-intensive. This might impact performance if splits are frequent. An alternative to minimize lock contention would be to copy `initialWatermark` and other necessary parameters to local variables inside the `synchronized` block and then call `constructSplitResult` outside the block. This would fix the race condition without extending the lock duration as much. Since this would require changes outside the current diff, feel free to keep this as is if the performance impact is acceptable, or address it in a follow-up.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix race condition in FnApiDoFnRunner.java [beam]
Posted by "jrmccluskey (via GitHub)" <gi...@apache.org>.
jrmccluskey commented on PR #35757:
URL: https://github.com/apache/beam/pull/35757#issuecomment-3155698899
assign set of reviewers
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix race condition in FnApiDoFnRunner.java [beam]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #35757:
URL: https://github.com/apache/beam/pull/35757#issuecomment-3141415281
Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment `assign set of reviewers`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix race condition in FnApiDoFnRunner.java [beam]
Posted by "Abacn (via GitHub)" <gi...@apache.org>.
Abacn merged PR #35757:
URL: https://github.com/apache/beam/pull/35757
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix race condition in FnApiDoFnRunner.java [beam]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #35757:
URL: https://github.com/apache/beam/pull/35757#issuecomment-3155701958
Assigning reviewers:
R: @m-trieu 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).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org