Closed jquesada-CLGX closed 1 year ago
Hello @jquesada-CLGX ,
I don't understand the problem, but re-opening connection inside SpringManagedTransaction
may not be the right solution.
If it's a new connection, it's not the same transaction anymore, you know.
In general, if a connection is closed unexpectedly, there should be an exception. You might have to set proper timeout depending on the situation, though (e.g. network timeout).
Close because no reply at long time. Of course you can reopen at any time. And probably, if calling the openConnection
again, this behavior cannot be resolved because the real connection managed by Spring Transaction (DataSourceUtils#getConnection
method return same connection instance during perform transaction).
Or another suggestion to solve this?
If you need retry, please consider to retry the transactional processing on other transaction. For example, you can use the Spring Retry feature.
SpringManagedTransaction is never trying to reconnect, making mandatory to restart the application to get this method available.
Really?? A SpringManagedTransaction
instance create at beginning new transaction. Therefore, I cannot believe this behavior. If you reopen this issue, please provide a repro project. Thanks.
We have a defined mapper calling an oracle stored procedure, the connections are managed by Hikari pool library. In some cases we have network issues making the DB not accessible for some time. After that the network is back but when trying to call the stored procedure the connection is always closed, SpringManagedTransaction is never trying to reconnect, making mandatory to restart the application to get this method available.
We have the following dependencies:
Defining the following simplified mapper:
Datasource and session configuration
When the connection is available in org.mybatis.spring.transaction.SpringManagedTransaction getConnection method we can see that the connection class type is (wrapping a ojdc connection object): HikariProxyConnection@1231378000 wrapping oracle.jdbc.driver.T4CConnection@1f5b0c71
When the network is lost the DB connection type is: HikariProxyConnection@1231378000 wrapping com.zaxxer.hikari.pool.ProxyConnection.ClosedConnection
After restablish the network connection the DB connection still the same HikariProxyConnection@1231378000 wrapping com.zaxxer.hikari.pool.ProxyConnection.ClosedConnection
In this line the connection is never more null but it is closed and the code never tries to reconnect https://github.com/mybatis/spring/blob/master/src/main/java/org/mybatis/spring/transaction/SpringManagedTransaction.java#L66
This could be fixed easily checking if the connection is closed at that point:
Or another suggestion to solve this?