beam icon indicating copy to clipboard operation
beam copied to clipboard

Fix out of range

Open liferoad opened this issue 7 months ago • 4 comments

Fixes https://github.com/apache/beam/issues/30177


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.

liferoad avatar May 26 '25 18:05 liferoad

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

github-actions[bot] avatar May 26 '25 21:05 github-actions[bot]

Assigning reviewers:

R: @Abacn 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).

github-actions[bot] avatar May 26 '25 23:05 github-actions[bot]

Reminder, please take a look at this pr: @Abacn

github-actions[bot] avatar Jun 09 '25 12:06 github-actions[bot]

Assigning new set of reviewers because Pr has gone too long without review. If you would like to opt out of this review, comment assign to next reviewer:

R: @ahmedabu98 for label java.

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)

github-actions[bot] avatar Jun 11 '25 12:06 github-actions[bot]

Reminder, please take a look at this pr: @ahmedabu98

github-actions[bot] avatar Jun 19 '25 12:06 github-actions[bot]

Assigning new set of reviewers because Pr has gone too long without review. If you would like to opt out of this review, comment assign to next reviewer:

R: @chamikaramj for label java.

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)

github-actions[bot] avatar Jun 23 '25 12:06 github-actions[bot]

Reminder, please take a look at this pr: @chamikaramj

github-actions[bot] avatar Jul 01 '25 12:07 github-actions[bot]

https://github.com/apache/beam/pull/35051#discussion_r2112122889 @yirutang I assume there is no potential data loss here.

liferoad avatar Jul 04 '25 13:07 liferoad

LGTM, but need to clean up the unused exception.

Also is it possible to add a test for this?

I do not have a good way to test this. I think the current PR wont do any harm at least since for streaming, the bug makes the pipeline stuck.

liferoad avatar Jul 04 '25 13:07 liferoad

Assigning new set of reviewers because Pr has gone too long without review. If you would like to opt out of this review, comment assign to next reviewer:

R: @robertwb for label java.

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)

github-actions[bot] avatar Jul 09 '25 12:07 github-actions[bot]

Reminder, please take a look at this pr: @robertwb

github-actions[bot] avatar Jul 16 '25 12:07 github-actions[bot]

Maybe it's too much to add an integration test here. But we can try running it locally with modified code that forces an end of stream error. Can you try adding an increment to the offset in the line below and running a pipeline locally to see if your new code path gets triggered? e.g. return datasetService.flush(streamId, offset + 50);

https://github.com/apache/beam/blob/52e42d72df16dace19674508d448bf6f0f92a4f6/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/StorageApiFlushAndFinalizeDoFn.java#L157

ahmedabu98 avatar Jul 16 '25 12:07 ahmedabu98

Maybe it's too much to add an integration test here. But we can try running it locally with modified code that forces an end of stream error. Can you try adding an increment to the offset in the line below and running a pipeline locally to see if your new code path gets triggered? e.g. return datasetService.flush(streamId, offset + 50);

https://github.com/apache/beam/blob/52e42d72df16dace19674508d448bf6f0f92a4f6/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/StorageApiFlushAndFinalizeDoFn.java#L157

Good idea. Manually changed the offset and ran this:

./gradlew :sdks:java:io:google-cloud-platform:integrationTest --tests "org.apache.beam.sdk.io.gcp.bigquery.BigQueryIOStorageWriteIT.testBigQueryStorageWrite3MProto" -PgcpProject=apache-beam-testing -PgcpTempRoot=gs://temp-storage-for-end-to-end-tests -i > test_output.log

testBigQueryStorageWrite3MProto failed as expected and also I added the log to test isOffsetBeyondEndOfStreamError is called with

private boolean isOffsetBeyondEndOfStreamError(Throwable t) {
    LOG.info("Checking for offset beyond end of stream error.");
    if (t == null) {
      return false;
    }
Jul 19, 2025 2:51:21 PM org.apache.beam.sdk.io.gcp.bigquery.StorageApiFlushAndFinalizeDoFn isOffsetBeyondEndOfStreamError
    INFO: Checking for offset beyond end of stream error.
 Jul 19, 2025 2:51:21 PM org.apache.beam.sdk.io.gcp.bigquery.StorageApiFlushAndFinalizeDoFn lambda$process$1
    WARNING: Flush of stream projects/apache-beam-testing/datasets/big_query_storage_write_it_1752951070961_24/tables/storage_write_1752951073468/streams/Cic2YmJiYjNlNS0wMDAwLTIwMmQtYWI0NS1kNGY1NDdmZDExZDQ6czQ to offset 1499 failed because the offset is beyond the end of the stream. This typically means the stream was finalized or truncated by BQ. The operation will not be retried on this stream. Error: com.google.api.gax.rpc.OutOfRangeException: io.grpc.StatusRuntimeException: OUT_OF_RANGE: Offset 1549 is beyond the end of the stream Entity: projects/apache-beam-testing/datasets/big_query_storage_write_it_1752951070961_24/tables/storage_write_1752951073468/streams/Cic2YmJiYjNlNS0wMDAwLTIwMmQtYWI0NS1kNGY1NDdmZDExZDQ6czQ
LOG.warn(
                    "Flush of stream {} to offset {} failed because the offset is beyond the end of the stream. "`
`` `
is also shown correctly.

liferoad avatar Jul 19 '25 19:07 liferoad