atomikos / transactions-essentials

Development repository for next major release of
https://www.atomikos.com/Main/TransactionsEssentials
Other
462 stars 139 forks source link

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

Open kyle-copeland opened 2 months ago

kyle-copeland commented 2 months ago

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

What TransactionsEssentials version you are using 6.0.109

Additional context Add any other context about the problem here.

kyle-copeland commented 2 months ago

Accidently opened issue before completing issue. Closing for now

kyle-copeland commented 2 months ago

Re-opening now that information is filled in

GuyPardon commented 2 months ago

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

ponziani commented 1 month ago

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.