-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
SQLTimeoutException closes connection #1388
Comments
Any progress on this issue? We have been facing this issue with Oracle that lead to partial commits. |
To explain our issue.
|
Hi, any news on this? I'm also quite surprised with the connection being closed in the event of a timeout. This kind of error is transient, as the OP explained. In our scenario, we are using Spring Data JPA, Eclipselink and Oracle DB. Spring sets a query timeout depending on the time left for the transaction (e.g. @transactional(timeout=20)). So, we can have a timeout either because of a long database call or because of the service chaining multiple calls and running out of time... Either way, I guess the connection is still alive and well; so it should not be closed. This behavior can impact performance because connections are not reused and need be created again. It also confuses logs. In our scenario, Spring tries to rollback the transaction because the last query failed, but the rollback itself fails due to the connection being closed. This does not seem to be proper rollback behavior. In order to know that this is motivated by a query timeout, one has to go backwards in the logs to find the cause error: "ORA-01013: user requested cancel of current operation". |
Hi , marked as broken because of SQLSTATE(HY008), ErrorCode(0)java.sql.SQLTimeoutException: The query has timed out. |
Same issue for me, this behavior should be considered as a regression. @talk2debendra @aritzbastida As mentionned in @johnou comment, you can implement the suggested workaround. it works fine for me for now. Just make sure you have a test for it to catch a further sneaky breaking change regarding that workaround.
And then you configure it on your Hikari datasource :
|
This is serious behavior. since the atomicity of the database transaction is not respected! |
Are there any updates on this? I bumped into this issue when using @idkw's workaround works, but that seem rather hacky and introduces a compile-time dependency on Hikari. |
I'm still using my hacky workaround too. Thank you |
After digging for several hours around this, I completely removed Hikari and used plain SQLServer JDBC data source instead. The problem was gone and then I ended up here. @idkw Is your workaround still valid for version |
Any news on this? We also have the same issue. I think it is even wrong to just close the connection on evict. The JDBC close method documentation has this warning: |
Ok, I will investigate a setting for evict-on-timeout, but a setting that applies only to statement-level timeouts, not connection-level timeouts. |
A setting for evict-on-timeout is only a workaround that does not solve the underlying problem. The real problem is that on eviction, a connection is only closed but not rolled back (which it should according to the JDBC close method documentation, see comment from @boonelschenbroich on Sep 6). Evict in case of other exceptions would still commit with Oracle (if the connection still communicates with the DB). From my point of view, the missing |
If someone is able to create a pull request with a fix for this as well as sufficient junit test coverage, I will be happy to review and merge it. |
Hi Folks! We have faced this exact same issue (partial commit) involving a Spring Boot application that interacts with Oracle. We are going to try the workaround above, but it would be great if we can have this behaviour configurable so that a rollback is always done if a connection is closed by Hikari due to timeouts |
Environment
If executing a java.sql.Statement results in a SQLTimeoutException then Hikari loggs a warning and force closes the connection.
The java.sql.SQLTimeoutException extends java.sql.SQLTransientException and that clearly states in the documentation that
So the JDBC specification says that the connection is still alive and well after a timeout so Hikari should not log a warning or close the connection!
It is up to the application to catch any SQLTimeoutException and either retry or throw exception and close the connection.
This bug was introduced in fix of #1308.
Right now it is impossible to use Hikari with code like this that works just fine when using a raw SQL Server JDBC connection:
The text was updated successfully, but these errors were encountered: