Skip to content

Fix out of range#35051

Merged
liferoad merged 11 commits intoapache:masterfrom
liferoad:fix-OutOfRange
Jul 20, 2025
Merged

Fix out of range#35051
liferoad merged 11 commits intoapache:masterfrom
liferoad:fix-OutOfRange

Conversation

@liferoad
Copy link
Contributor

Fixes #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 liferoad marked this pull request as ready for review May 26, 2025 21:11
@liferoad liferoad requested a review from ahmedabu98 May 26, 2025 21:11
@github-actions
Copy link
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

@github-actions
Copy link
Contributor

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).

@liferoad liferoad requested review from Abacn and ahmedabu98 June 1, 2025 17:47
@github-actions
Copy link
Contributor

github-actions bot commented Jun 9, 2025

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

@github-actions
Copy link
Contributor

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
Copy link
Contributor

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

@github-actions
Copy link
Contributor

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
Copy link
Contributor

github-actions bot commented Jul 1, 2025

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

Copy link
Contributor

@ahmedabu98 ahmedabu98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but need to clean up the unused exception.

Also is it possible to add a test for this?

@liferoad
Copy link
Contributor Author

liferoad commented Jul 4, 2025

#35051 (comment) @yirutang I assume there is no potential data loss here.

@liferoad
Copy link
Contributor Author

liferoad commented Jul 4, 2025

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 liferoad requested review from ahmedabu98 and yirutang July 4, 2025 13:37
@github-actions
Copy link
Contributor

github-actions bot commented Jul 9, 2025

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
Copy link
Contributor

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

@ahmedabu98
Copy link
Contributor

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);

@liferoad
Copy link
Contributor Author

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);

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.

Copy link
Contributor

@ahmedabu98 ahmedabu98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, LGTM. Thanks for running it

@liferoad liferoad merged commit 5696b6e into apache:master Jul 20, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: BigQuery streaming throwing OutOfRangeException

4 participants