Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-10755

JDBC Connection is not released due to incorrectly defined catch

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Complete
    • Affects Version/s: 3.2.3
    • Fix Version/s: 3.2.4, 4.0 M2
    • Component/s: Core
    • Labels:
      None
    • Last commented by a User:
      true

      Description

      DataSourceTransactionManager contains a bug when releasing the connection. According to the official recommendation, The problem here is that the code only releases the connection when an exception occurs, not when an Error. In our case when an OutOfMemoryError occurs we notice that the connections are not released. Here is the code snipped from doBegin()

      try {
      
      ...
      catch (Exception ex) {
      	DataSourceUtils.releaseConnection(con, this.dataSource);
      	throw new CannotCreateTransactionException("Could not open JDBC Connection for transaction", ex);
      }
      

      The problem is that OOM can be recovered, but not releasing the connections cannot be recovered.

      Not sure how much it is related, but when I see abandoned JDBC connections I also see these in the log file :

      org.springframework.transaction.TransactionSystemException: Could not roll back JDBC transaction; nested exception is java.sql.SQLException: Connection com.microsoft.sqlserver.jdbc.SQLServerConnection@266290d7 is closed.
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                juergen.hoeller Juergen Hoeller
                Reporter:
                szantopeter Peter Szanto
                Last updater:
                Spring Issuemaster
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  40 weeks, 1 day ago