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

HikariCP does not evict (and call connection close) on Query Timeout #1308

Closed
jbialos opened this issue Dec 31, 2018 · 2 comments
Closed

HikariCP does not evict (and call connection close) on Query Timeout #1308

jbialos opened this issue Dec 31, 2018 · 2 comments

Comments

@jbialos
Copy link

jbialos commented Dec 31, 2018

Environment

HikariCP version: 2.7.8
JDK version     : jdk1.8.0_45
Database        : MS SQL SERVER
Driver version  : 7.0.0.jre8

More configuration:

Auto commit: true
TransactionIsolationLevel: default (TRANSACTION_READ_COMMITTED)
Query Timeout: set in jdbc url 10 seconds
Socket Timeout: set in jdbc url 11000 ms
Max Lifetime: 600000

I'm moving a legacy application over to hikaricp. When a query times out and the driver throws a java.sql.SQLTimeoutException, the legacy connection pool evicts and closes the underlying MS SQL Driver connection. Upon SQLTimeoutException, HikariCP just closes the statement and does not evict.

The HikariCP behavior leaves a bunch of sleeping spids on the DB with open transactions. This is unacceptable for my specific use-case and DB configuration.

I can hack it and just call HikariDataSource.evictConnection() from my application code when the driver throws a SQLException that I deem unrecoverable. This fixes my problem. Am I missing the proper way to do this through configuration?

@brettwooldridge
Copy link
Owner

@jbialos This is a little curious to me. Can you post your configuration?

By default, when you close the connection (presumably in a try-with-resources or finally block), any "in-flight" (uncommitted) transaction should be rolled back by HikariCP. I also recommend upgrading to the latest HikariCP version to see if the issue still occurs.

@jbialos
Copy link
Author

jbialos commented Jan 30, 2019

I have confirmed that cda2605 fixes the original problem in our system. Thanks!

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

No branches or pull requests

2 participants