You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by "Suvrat1629 (via GitHub)" <gi...@apache.org> on 2025/08/22 18:54:13 UTC
[PR] [Java]Fix IllegalStateException in WindmillSink by Clearing Stream Before Encoding (#31914) [beam]
Suvrat1629 opened a new pull request, #35942:
URL: https://github.com/apache/beam/pull/35942
**Please** add a meaningful description for your change here
------------------------
Fixes #31914 by adding stream.toByteStringAndReset() before each encode call in WindmillSink$WindmillStreamWriter.add to clear residual data, preventing IllegalStateException.
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] [Java]Fix IllegalStateException in WindmillSink by Clearing Stream Before Encoding (#31914) [beam]
Posted by "scwhittle (via GitHub)" <gi...@apache.org>.
scwhittle merged PR #35942:
URL: https://github.com/apache/beam/pull/35942
--
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] [Java]Fix IllegalStateException in WindmillSink by Clearing Stream Before Encoding (#31914) [beam]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #35942:
URL: https://github.com/apache/beam/pull/35942#issuecomment-3215410107
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] [Java]Fix IllegalStateException in WindmillSink by Clearing Stream Before Encoding (#31914) [beam]
Posted by "Suvrat1629 (via GitHub)" <gi...@apache.org>.
Suvrat1629 commented on code in PR #35942:
URL: https://github.com/apache/beam/pull/35942#discussion_r2297788242
##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/WindmillSink.java:
##########
@@ -155,10 +155,12 @@ private <EncodeT> ByteString encode(Coder<EncodeT> coder, EncodeT object) throws
public long add(WindowedValue<T> data) throws IOException {
ByteString key, value;
ByteString id = ByteString.EMPTY;
+ stream.toByteStringAndReset();
Review Comment:
@scwhittle Thanks for the feedback.
I have updated the fix to wrap `coder.encode` in a try-catch in encode, resetting stream on exception and I have reverted add method back to its original state. Please take a look.
Thank you
--
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] [Java]Fix IllegalStateException in WindmillSink by Clearing Stream Before Encoding (#31914) [beam]
Posted by "Suvrat1629 (via GitHub)" <gi...@apache.org>.
Suvrat1629 commented on PR #35942:
URL: https://github.com/apache/beam/pull/35942#issuecomment-3220092734
@scwhittle
Ok sure thank you :)
--
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] [Java]Fix IllegalStateException in WindmillSink by Clearing Stream Before Encoding (#31914) [beam]
Posted by "tvalentyn (via GitHub)" <gi...@apache.org>.
tvalentyn commented on PR #35942:
URL: https://github.com/apache/beam/pull/35942#issuecomment-3219539394
R: @scwhittle
--
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] [Java]Fix IllegalStateException in WindmillSink by Clearing Stream Before Encoding (#31914) [beam]
Posted by "scwhittle (via GitHub)" <gi...@apache.org>.
scwhittle commented on code in PR #35942:
URL: https://github.com/apache/beam/pull/35942#discussion_r2297932323
##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/WindmillSink.java:
##########
@@ -146,8 +146,15 @@ private <EncodeT> ByteString encode(Coder<EncodeT> coder, EncodeT object) throws
stream.size() == 0,
"Expected output stream to be empty but had %s",
stream.toByteString());
- coder.encode(object, stream, Coder.Context.OUTER);
- return stream.toByteStringAndReset();
+ ByteString result;
+ try {
+ coder.encode(object, stream, Coder.Context.OUTER);
+ result = stream.toByteStringAndReset();
+ } catch (IOException e) {
Review Comment:
How about catching Exception e? in case there is a RuntimeException the coder throws
##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/WindmillSink.java:
##########
@@ -146,8 +146,15 @@ private <EncodeT> ByteString encode(Coder<EncodeT> coder, EncodeT object) throws
stream.size() == 0,
"Expected output stream to be empty but had %s",
stream.toByteString());
- coder.encode(object, stream, Coder.Context.OUTER);
- return stream.toByteStringAndReset();
+ ByteString result;
+ try {
+ coder.encode(object, stream, Coder.Context.OUTER);
+ result = stream.toByteStringAndReset();
Review Comment:
nit: I think you can just
`return stream.toByteStringAndReset();`
and remove the result variable
--
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] [Java]Fix IllegalStateException in WindmillSink by Clearing Stream Before Encoding (#31914) [beam]
Posted by "Suvrat1629 (via GitHub)" <gi...@apache.org>.
Suvrat1629 commented on PR #35942:
URL: https://github.com/apache/beam/pull/35942#issuecomment-3216560048
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] [Java]Fix IllegalStateException in WindmillSink by Clearing Stream Before Encoding (#31914) [beam]
Posted by "scwhittle (via GitHub)" <gi...@apache.org>.
scwhittle commented on code in PR #35942:
URL: https://github.com/apache/beam/pull/35942#discussion_r2297627751
##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/WindmillSink.java:
##########
@@ -155,10 +155,12 @@ private <EncodeT> ByteString encode(Coder<EncodeT> coder, EncodeT object) throws
public long add(WindowedValue<T> data) throws IOException {
ByteString key, value;
ByteString id = ByteString.EMPTY;
+ stream.toByteStringAndReset();
Review Comment:
It seems the issue is likely that an exception is being thrown from line 149 `coder.encode` which causes line 150 not to reset the stream. Then if at a higher level that exception is caught and ignored and further encoding is attempted the checkState will be encountered.
Since this is executed often it seems it would be better to fix by changing `encode` to wrap the existing logic with try/catch and resetting the stream before propagating an exception thrown by the coder, instead of the additional resets here.
--
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] [Java]Fix IllegalStateException in WindmillSink by Clearing Stream Before Encoding (#31914) [beam]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #35942:
URL: https://github.com/apache/beam/pull/35942#issuecomment-3219542934
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] [Java]Fix IllegalStateException in WindmillSink by Clearing Stream Before Encoding (#31914) [beam]
Posted by "Suvrat1629 (via GitHub)" <gi...@apache.org>.
Suvrat1629 commented on code in PR #35942:
URL: https://github.com/apache/beam/pull/35942#discussion_r2297961695
##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/WindmillSink.java:
##########
@@ -146,8 +146,15 @@ private <EncodeT> ByteString encode(Coder<EncodeT> coder, EncodeT object) throws
stream.size() == 0,
"Expected output stream to be empty but had %s",
stream.toByteString());
- coder.encode(object, stream, Coder.Context.OUTER);
- return stream.toByteStringAndReset();
+ ByteString result;
+ try {
+ coder.encode(object, stream, Coder.Context.OUTER);
+ result = stream.toByteStringAndReset();
Review Comment:
Done!
##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/WindmillSink.java:
##########
@@ -146,8 +146,15 @@ private <EncodeT> ByteString encode(Coder<EncodeT> coder, EncodeT object) throws
stream.size() == 0,
"Expected output stream to be empty but had %s",
stream.toByteString());
- coder.encode(object, stream, Coder.Context.OUTER);
- return stream.toByteStringAndReset();
+ ByteString result;
+ try {
+ coder.encode(object, stream, Coder.Context.OUTER);
+ result = stream.toByteStringAndReset();
+ } catch (IOException e) {
Review Comment:
Done!
--
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] [Java]Fix IllegalStateException in WindmillSink by Clearing Stream Before Encoding (#31914) [beam]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #35942:
URL: https://github.com/apache/beam/pull/35942#issuecomment-3216560846
Assigning reviewers:
R: @tvalentyn added as fallback since no labels match configuration
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