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

waitForAtLeastOneAvailableConnection waits for total borrowConnectionTimeout reducing potential ability to borrow connection #224

Open
kyle-copeland opened this issue Jun 26, 2024 · 4 comments

Comments

@kyle-copeland
Copy link

kyle-copeland commented Jun 26, 2024

Describe the bug
When multiple threads attempt to grab database connections, Atomikos will at most attempt to grow the pool twice before failing, regardless of the borrowConnectionTimeout.

To Reproduce
Steps to reproduce the behavior:

  1. Thread A attempts to grab a database connection
  2. Thread A can't find one and grows the connections available
  3. Thread B takes that connection
  4. Thread A will wait for the remainder of borrowConnectionTimeout in waitForAtLeastOneAvailableConnection
  5. Thread A will loop and perform steps 1,2,4 again
  6. Thread C will take that connection
  7. Thread A will exit in waitForAtLeastOneAvailableConnection

What you were doing (or trying to do):
When our app boots, we spin up multiple worker threads. These threads all query the database to see if they have work to perform.

sessionFactory.getCurrentSession().createQuery("...").getResultList();

What happened
We infrequently get:

AtomikosSQLException: Connection pool exhausted - try increasing 'maxPoolSize' and/or 'borrowConnectionTimeout' on the DataSourceBean.

What you expected to happen instead
Some ideas

  • Have Atomikos wait to grab a connection at a set interval with a maximum of borrowConnectionTimeout. This would mean replacing wait(remainderOfTime), with some wait(fractionOfRemainerOftime) here.

  • Have Atomikos guarantee that the connection created in grow() is granted to the thread requesting a connection.

What TransactionsEssentials version you are using
6.0.109

Additional context
Add any other context about the problem here.

@kyle-copeland
Copy link
Author

Accidently opened issue before completing issue. Closing for now

@kyle-copeland kyle-copeland closed this as not planned Won't fix, can't repro, duplicate, stale Jun 26, 2024
@kyle-copeland kyle-copeland changed the title Change waitForAtLeastOneAvailableConnection waits for total borrowConnectionTimeout preventing potential ability to borrow connection Jun 26, 2024
@kyle-copeland kyle-copeland changed the title waitForAtLeastOneAvailableConnection waits for total borrowConnectionTimeout preventing potential ability to borrow connection waitForAtLeastOneAvailableConnection waits for total borrowConnectionTimeout reducing potential ability to borrow connection Jun 26, 2024
@kyle-copeland
Copy link
Author

Re-opening now that information is filled in

@kyle-copeland kyle-copeland reopened this Jun 26, 2024
@GuyPardon
Copy link
Contributor

Thanks for reporting this! Your first suggestion sounds feasible in the short term, the second one might be more involved?

@ponziani
Copy link

We're experiencing the same problem after upgrading from 3.8.0 to 5.0.9, I guess we will increase the minPoolSize for now, but we will also be looking forward to a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants