Skip to content

Conversation

@damccorm
Copy link
Contributor

@damccorm damccorm commented Feb 24, 2025

It seems that not all Datasources are thread safe when creating connections and can hang when many threads try to create connections at once. Since datasources can be shared across threads, this creates a problem. This pr attempts to resolve the problem, though right now I'm mostly using it to test/validate the fix.

Fixes #34120


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.

@damccorm
Copy link
Contributor Author

Launching some performance tests to see if this change has any impact: https://github.com/apache/beam/actions/runs/13592236722

I'm hopeful it won't since:

  1. It should only be paid once per bundle
  2. Actually reading/writing should be the dominant part of this workload, not getting a connection. If getting a connection is slow, that probably means that there just aren't enough connections to go around

@damccorm
Copy link
Contributor Author

Yeah, seems like little to no perf impact.

My run with this change:

image

Previous 5 runs:

run 1:

image

run 2:

image

run 3:

image

run 4:

image

run 5:

image

My updated version actually did the best here on both metrics, so it seems like it should be pretty safe.

@damccorm damccorm marked this pull request as ready for review February 28, 2025 17:31
@github-actions
Copy link
Contributor

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

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

@damccorm
Copy link
Contributor Author

R: @Abacn

@github-actions
Copy link
Contributor

Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment assign set of reviewers

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!

@damccorm damccorm merged commit 468001b into master Mar 1, 2025
17 checks passed
@damccorm damccorm deleted the users/damccorm/jdbcPatch branch March 1, 2025 01:20
@liferoad
Copy link
Contributor

liferoad commented Mar 1, 2025

Shall we call this out in CHANGES.md?

@damccorm
Copy link
Contributor Author

damccorm commented Mar 3, 2025

Shall we call this out in CHANGES.md?

Sure, #34147

VardhanThigle pushed a commit to VardhanThigle/beam that referenced this pull request Mar 21, 2025
* Update JdbcIO.java

* Fix vars

* Fix typing problems

* Use lineage check so that we maintain safety

* Remove dupe assignment

* Assign correctly inside lock to avoid race

* Add other getConnection

* Fix bad merge

* Remove unneeded logs

* Shrink critical section

* Cleanup

* Fix bad refactor

* typo
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]: Fix JdbcIO Thread contention

3 participants