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

[JdbcIO] - Adding option for max batch buffering duration #30259

Merged
merged 6 commits into from
Feb 12, 2024

Conversation

scott-strong
Copy link
Contributor

Currently the max buffering duration for batch processing during JDBC writes is not configurable and defaulted to 200ms. I'm proposing that we add an option to configure this setting to allow for a longer duration period to accumulate batched elements. We've run into an issue where batches are committed too frequently causing many small batches to be written rather than fewer larger batches, and I'm hoping to tweak this setting to allow for the latter.


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.

@scott-strong scott-strong changed the title Adding option for max batch buffering duration [JdbcIO] - Adding option for max batch buffering duration Feb 8, 2024
Copy link
Contributor

github-actions bot commented Feb 8, 2024

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

@scott-strong
Copy link
Contributor Author

test failures here seem unrelated but I can't re-run, going to assign reviewers

@scott-strong
Copy link
Contributor Author

assign set of reviewers

Copy link
Contributor

github-actions bot commented Feb 8, 2024

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

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

Copy link
Contributor

github-actions bot commented Feb 8, 2024

Reviewers are already assigned to this PR: @Abacn @chamikaramj

@Abacn
Copy link
Contributor

Abacn commented Feb 8, 2024

The idea sounds good to me.

There are two options controlling the batch, batch_size and buffering_duration.

For example, if batch_size set to 100 and buffering_duration=200ms.

  • if batch size reaches 1000 within 100ms
  • if batch size does not reach 1000 within 200ms

If I understood correctly, in both cases, the pipeline will commit the buffer? Good to add some documentation about the spec.

@scott-strong
Copy link
Contributor Author

@Abacn yes exactly, so currently we can increase the batch size but not the max buffering duration. Each is a way to configure when the pipeline will commit the buffer. I can add documentation about this.

@scott-strong
Copy link
Contributor Author

@Abacn I added more to the javadoc for both withBatchSize and withMaxBatchBufferingDuration, let me know if it sounds good to you

@Abacn
Copy link
Contributor

Abacn commented Feb 9, 2024

Thanks. For the Spotless (formatting) check failure, please run ./gradlew :sdks:java:io:jdbc:spotlessApply then push the changes

Copy link
Contributor

@Abacn Abacn left a comment

Choose a reason for hiding this comment

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

Thanks for the changes. Just had one comment

@@ -1971,6 +1982,7 @@ public PCollection<V> expand(PCollection<T> input) {
.setRetryConfiguration(getRetryConfiguration())
.setReturnResults(true)
.setBatchSize(1L)
.setMaxBatchBufferingDuration(200L)
Copy link
Contributor

Choose a reason for hiding this comment

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

Use the constant (DEFAULT_MAX_BATCH_BUFFERING_DURATION) as it is defined there

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks, just made that change

Copy link
Contributor

@Abacn Abacn left a comment

Choose a reason for hiding this comment

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

Thank you!

@Abacn Abacn merged commit fa32492 into apache:master Feb 12, 2024
18 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.

2 participants