Add SessionPoolOptions to SpannerConfig
Add support for configuring SessionPoolOptions in SpannerAccessor.
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, commentfixes #<ISSUE NUMBER>instead. - [ ] Update
CHANGES.mdwith 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)
See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.
Assigning reviewers. If you would like to opt out of this review, comment assign to next reviewer:
R: @robertwb for label java. R: @damondouglas for label io. R: @nielm for label spanner.
Available commands:
stop reviewer notifications- opt out of the automated review toolingremind me after tests pass- tag the comment author after tests passwaiting 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).
Can you explain why you believe this is necessary to add?
The default session pool options in Java are:
- MinSessions =100
- MaxSessions = 400
- WriteSessionsFraction = 0.2
These will apply to each worker indivudually.
@olavloite for comment.
This is my primary motivation - https://github.com/googleapis/java-spanner/blob/main/session-and-channel-pool-configuration.md#automatically-clean-inactive-transactions
Currently, there is no way to set setWarnAndCloseIfInactiveTransactions(). SpannerAccessor is used in Dataflow templates like DatastreamToSpanner, which customers use as a black box, therefore, having this enabled by default makes sense.
In theory there should never be an inactive transaction left open by SpannerIO. If there is, then it is a bug in SpannerIO.
Writes use blind writes by calling DatabaseClient.writeAtLeastOnce, which internally uses the single_use_transaction feature of the Commit API so that a transaction is automatically started and closed by the Spanner server.
Reads use a single read transaction, which is shared across all workers. By their nature these are long-running transactions.
SpannerIO is intended to isolate users from needing to worry about transactions, and to just pass their data in and let the connecter deal with it.
If you are experiencing issues with session pool exhaustion, and believe that there may be a bug, then please raise an issue.
SpannerAccessor is not only consumed by SpannerIO, it is directly used by Flex templates such as DatastreamToSpanner here. Therefore a pipeline may leverage the accessor from beam directly and have a session leak in the application code they write using the accessor.
Reminder, please take a look at this pr: @robertwb @damondouglas @nielm
Bump! @nielm @olavloite
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: @kennknowles for label java. R: @ahmedabu98 for label io. R: @nielm for label spanner.
Available commands:
stop reviewer notifications- opt out of the automated review toolingremind me after tests pass- tag the comment author after tests passwaiting 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)
Result of out-of-band discussion between @manitgupta and @olavloite - Change the PR such that SpannerAccessor always sets
SessionPoolOptions.setFailIfPoolExhausted()
to avoid expanding the SpannerIO public API surface while also catching potential session leak bugs.
LGTM
Precommit fails for unrelated reason in
org.apache.beam.sdk.io.gcp.spanner.changestreams.it.SpannerChangeStreamOrderedWithinKeyIT > restOrderedWithinKey
Reminder, please take a look at this pr: @kennknowles @ahmedabu98 @nielm
reverted in #32694