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

[BEAM-9629] Fix several connection leak issues. #12209

Merged
merged 1 commit into from
Jul 10, 2020

Conversation

lukecwik
Copy link
Member

@lukecwik lukecwik commented Jul 9, 2020

  • Make the default max connections to be unlimited. This mirrors the 2.17 and earlier behavior since we used to create one DataSource per execution thread (and hence one connection).
  • Move connection fetching to @ProcessElement to not hold a connection for empty bundles.
  • Make sure that finalize() closes the connection so that it is returned to the pool if the bundle fails.

Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Choose reviewer(s) and mention them in a comment (R: @username).
  • Format the pull request title like [BEAM-XXX] Fixes bug in ApproximateQuantiles, where you replace BEAM-XXX with the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.
  • 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.

Post-Commit Tests Status (on master branch)

Lang SDK Dataflow Flink Samza Spark Twister2
Go Build Status --- Build Status --- Build Status ---
Java Build Status Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status Build Status
Build Status
Build Status
Build Status
Python Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
--- Build Status ---
XLang --- --- Build Status --- Build Status ---

Pre-Commit Tests Status (on master branch)

--- Java Python Go Website
Non-portable Build Status Build Status
Build Status
Build Status Build Status
Portable --- Build Status --- ---

See .test-infra/jenkins/README for trigger phrase, status and link of all Jenkins jobs.

* Make the default max connections to be unlimited. This mirrors the 2.17 and earlier behavior since we used to create one DataSource per execution thread (and hence one connection).
* Move connection fetching to @ProcessElement to not hold a connection for empty bundles.
* Make sure that finalize() closes the connection so that it is returned to the pool if the bundle fails.
@lukecwik
Copy link
Member Author

lukecwik commented Jul 9, 2020

R: @iemejia @TheNeuralBit @jbonofre

@TheNeuralBit TheNeuralBit self-requested a review July 9, 2020 22:08
Copy link
Member

@iemejia iemejia left a comment

Choose a reason for hiding this comment

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

LGTM

* <p>By default, the provided function requests a DataSource per execution thread. In some
* circumstances this can quickly overwhelm the database by requesting too many connections. In that
* case you should look into sharing a single instance of a {@link PoolingDataSource} across all the
* execution threads.
Copy link
Member

Choose a reason for hiding this comment

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

Since this is a recurrent issue for users I am wondering if It would probably be good to add a snippet of how to achieve this (maybe in a subsequent PR since it is not exactly related).

Copy link
Member Author

Choose a reason for hiding this comment

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

Done in #12220

@lukecwik lukecwik merged commit 47a6114 into apache:master Jul 10, 2020
yirutang pushed a commit to yirutang/beam that referenced this pull request Jul 23, 2020
* Make the default max connections to be unlimited. This mirrors the 2.17 and earlier behavior since we used to create one DataSource per execution thread (and hence one connection).
* Move connection fetching to @ProcessElement to not hold a connection for empty bundles.
* Make sure that finalize() closes the connection so that it is returned to the pool if the bundle fails.
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