-
Notifications
You must be signed in to change notification settings - Fork 695
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
fix: EXPOSED-133 Suspend transactions blocking Hikari connection pool #1837
Conversation
If the maximumPoolSize of a HikariDataSource is reached, the active connections made through newSuspendedTransaction() are not being released back into the pool, leading to a connection timeout exception when attempting to get more connections. resetIfClosed(), in suspendedTransactionAsyncInternal(), calls getConnection() to check if the transaction is closed (may happen after a repetition attempt), so that it can be properly reset for a new attempt. This blocks the connections being released and should not be necessary for the first loop, as the created transaction has an open connection. resetIfClosed() is now only accessed on subsequent repetition attempt loops.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add h2
dependency in exposed-tests
to make a test, it's not a published module so it should be fine
Add Hikari CP dependency in exposed-tests module. Add new test suite for Hikari CP.
Switch H2 test dependency to compileOnly to avoid exposed-java-time build failures.
@e5l Switching A dependency on Hikari CP was still included with a new unit test by letting |
…JetBrains#1837) * fix: EXPOSED-133 Suspend transactions blocking Hikari connection pool If the maximumPoolSize of a HikariDataSource is reached, the active connections made through newSuspendedTransaction() are not being released back into the pool, leading to a connection timeout exception when attempting to get more connections. resetIfClosed(), in suspendedTransactionAsyncInternal(), calls getConnection() to check if the transaction is closed (may happen after a repetition attempt), so that it can be properly reset for a new attempt. This blocks the connections being released and should not be necessary for the first loop, as the created transaction has an open connection. resetIfClosed() is now only accessed on subsequent repetition attempt loops.
If the
maximumPoolSize
of aHikariDataSource
is exceeded, any active connections made throughnewSuspendedTransaction()
are not released back into the pool after job completion. This leads to a connection timeout exception when attempting to get more connections.resetIfClosed()
, invoked insuspendedTransactionAsyncInternal()
, callsgetConnection()
to check if a transaction is closed (may happen after a repetition attempt fails), so that it can be properly reset for another attempt. This blocks the connections being released.The function was introduced in PR #1774 and should not be necessary for the first loop, as the transaction is created with an open connection.
Now
resetIfClosed()
is only called on subsequent repetition attempt loops.Unit test:
exposed-tests
module.exposed-tests/build.gradle.kts
, before running the test provided in the original YT issue: