Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress BigQuery read stream splitAtFraction when API busy call or timeout #31125

Merged
merged 5 commits into from May 6, 2024

Conversation

Abacn
Copy link
Contributor

@Abacn Abacn commented Apr 27, 2024

Resolve #30646 (comment)

  • Reject split attempt early when there is an ongoing hasNext call in work item thread

  • TImeout hasNext call in splitAtFraction in alignment with client splitReadStreamSettings

The issue exist on both released Beam and after #31096

Tested on read stream API v1 (default) and Dataflow legacy runner in a quota restricted project:

image

Without the change, the pipeline appears to stuck indefinitely. the onRetryAttempt callback get called periodically.

Please add a meaningful description for your change here


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.

…imeout

* Reject split attempt early when there is an ongoing hasNext call
  in work item thread

* TImeout hasNext call in splitAtFraction in alignment with client
  splitReadStreamSettings
try {
// The intended wait time is in sync with splitReadStreamSettings.setRetrySettings in
// StorageClientImpl.
future.get(30, TimeUnit.SECONDS);
Copy link
Contributor Author

@Abacn Abacn Apr 27, 2024

Choose a reason for hiding this comment

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

This is correspond to the config here

splitReadStreamSettings.setRetrySettings(
splitReadStreamSettings
.getRetrySettings()
.toBuilder()
.setInitialRpcTimeout(org.threeten.bp.Duration.ofSeconds(30))
.setMaxRpcTimeout(org.threeten.bp.Duration.ofSeconds(30))
.setTotalTimeout(org.threeten.bp.Duration.ofSeconds(30))
.build());

It intended to set the API call timeout during split request to 30s (and otherwise reject split). However, a bug fix #21739 added this call here, which has internal retry logic, but this added call is not covered by the split-stream-retry config above. When there is quota issue, this is causing pipeline stuck

latch.await();

// Beam does not split storage read api v2 stream
assertNull(reader.splitAtFraction(0.5));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

without the changes in main scope code, the test fails with

java.lang.NullPointerException
	at org.apache.beam.sdk.io.gcp.bigquery.BigQueryStorageStreamSource$BigQueryStorageStreamReader.splitAtFraction(BigQueryStorageStreamSource.java:372)

because it passed "splitAllowed" check

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

@@ -388,8 +398,22 @@ public synchronized BigQueryStorageStreamSource<T> getCurrentSource() {
// The following line is required to trigger the `FailedPreconditionException` on which
// the SplitReadStream validation logic depends. Removing it will cause incorrect
// split operations to succeed.
newResponseIterator.hasNext();
storageClient.reportPendingMetrics();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed reportPendingMetrics call here otherwise same warning as #31096 seen, because splitAtFraction call thread isn't a work item thread

Copy link
Contributor

Assigning reviewers. If you would like to opt out of this review, comment assign to next reviewer:

R: @damondouglas for label java.
R: @chamikaramj for label io.

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

@Abacn
Copy link
Contributor Author

Abacn commented Apr 30, 2024

R: @ahmedabu98 (since you reviewed #31096)

Copy link
Contributor

Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control

@Abacn Abacn added this to the 2.57.0 Release milestone May 2, 2024
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, just some cleanup

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 53.84615% with 6 lines in your changes are missing coverage. Please review.

Project coverage is 60.41%. Comparing base (b34cf54) to head (4b3dd6a).
Report is 122 commits behind head on master.

Files Patch % Lines
...k/io/gcp/bigquery/BigQueryStorageStreamSource.java 53.84% 6 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             master   #31125       +/-   ##
=============================================
- Coverage     71.44%   60.41%   -11.04%     
- Complexity     1474     2981     +1507     
=============================================
  Files           906      659      -247     
  Lines        113271    66095    -47176     
  Branches       1076     3233     +2157     
=============================================
- Hits          80931    39930    -41001     
+ Misses        30327    23066     -7261     
- Partials       2013     3099     +1086     
Flag Coverage Δ
java 68.62% <53.84%> (+0.04%) ⬆️
python ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Abacn Abacn merged commit 26c4ee4 into apache:master May 6, 2024
18 checks passed
@Abacn Abacn deleted the decreasehasnextcall branch May 6, 2024 19:36
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.

None yet

3 participants