OpenJPA
  1. OpenJPA
  2. OPENJPA-2440

foreign key drop leaks jdbc connections

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.3.0
    • Fix Version/s: 2.3.0
    • Component/s: None
    • Labels:
      None

      Description

      Hi some connections are not closed when dropping fk, here is a proposed patch:

      Index: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SchemaTool.java
      ===================================================================
      — openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SchemaTool.java (revision 1531344)
      +++ openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SchemaTool.java (working copy)
      @@ -18,6 +18,23 @@
      */
      package org.apache.openjpa.jdbc.schema;

      +import org.apache.commons.lang.StringUtils;
      +import org.apache.openjpa.conf.OpenJPAConfiguration;
      +import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
      +import org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl;
      +import org.apache.openjpa.jdbc.identifier.DBIdentifier;
      +import org.apache.openjpa.jdbc.sql.DBDictionary;
      +import org.apache.openjpa.jdbc.sql.SQLExceptions;
      +import org.apache.openjpa.lib.conf.Configurations;
      +import org.apache.openjpa.lib.jdbc.DelegatingDataSource;
      +import org.apache.openjpa.lib.log.Log;
      +import org.apache.openjpa.lib.meta.MetaDataSerializer;
      +import org.apache.openjpa.lib.util.Files;
      +import org.apache.openjpa.lib.util.Localizer;
      +import org.apache.openjpa.lib.util.Options;
      +import org.apache.openjpa.util.InvalidStateException;
      +
      +import javax.sql.DataSource;
      import java.io.File;
      import java.io.IOException;
      import java.io.PrintWriter;
      @@ -33,24 +50,7 @@
      import java.util.LinkedHashSet;
      import java.util.LinkedList;
      import java.util.Set;
      -import javax.sql.DataSource;

      -import org.apache.commons.lang.StringUtils;
      -import org.apache.openjpa.conf.OpenJPAConfiguration;
      -import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
      -import org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl;
      -import org.apache.openjpa.jdbc.identifier.DBIdentifier;
      -import org.apache.openjpa.jdbc.sql.DBDictionary;
      -import org.apache.openjpa.jdbc.sql.SQLExceptions;
      -import org.apache.openjpa.lib.conf.Configurations;
      -import org.apache.openjpa.lib.jdbc.DelegatingDataSource;
      -import org.apache.openjpa.lib.log.Log;
      -import org.apache.openjpa.lib.meta.MetaDataSerializer;
      -import org.apache.openjpa.lib.util.Files;
      -import org.apache.openjpa.lib.util.Localizer;
      -import org.apache.openjpa.lib.util.Options;
      -import org.apache.openjpa.util.InvalidStateException;
      -
      /**

      • The SchemaTool is used to manage the database schema. Note that the
      • tool never adds or drops unique constraints from existing tables, because
        @@ -1099,7 +1099,12 @@
        */
        public boolean dropForeignKey(ForeignKey fk)
        throws SQLException {
      • return executeSQL(_dict.getDropForeignKeySQL(fk,_ds.getConnection()));
        + final Connection connection = _ds.getConnection();
        + try { + return executeSQL(_dict.getDropForeignKeySQL(fk, connection)); + }

        finally

        { + connection.close(); + }

        }

      /**

        Activity

        Hide
        Mark Struberg added a comment -

        Actually I've found that our SchemaTool source is full with NOT freeing up our connections properly it seems.

        Show
        Mark Struberg added a comment - Actually I've found that our SchemaTool source is full with NOT freeing up our connections properly it seems.
        Hide
        Mark Struberg added a comment -

        patch against 2.3.x. Please review! Like to commit this tonight...

        Show
        Mark Struberg added a comment - patch against 2.3.x. Please review! Like to commit this tonight...
        Hide
        ASF subversion and git services added a comment -

        Commit 1533640 from Mark Struberg in branch 'openjpa/branches/2.3.x'
        [ https://svn.apache.org/r1533640 ]

        OPENJPA-2440 close connection after not using it anymore

        this prevents leaks like the one reported by rmannibucau.

        Show
        ASF subversion and git services added a comment - Commit 1533640 from Mark Struberg in branch 'openjpa/branches/2.3.x' [ https://svn.apache.org/r1533640 ] OPENJPA-2440 close connection after not using it anymore this prevents leaks like the one reported by rmannibucau.
        Hide
        Mark Struberg added a comment -

        Thanks for the report, Romain!

        I also fixed the other similar situations. Applied to 2.3.x and trunk

        Show
        Mark Struberg added a comment - Thanks for the report, Romain! I also fixed the other similar situations. Applied to 2.3.x and trunk
        Hide
        ASF subversion and git services added a comment -

        Commit 1533641 from Mark Struberg in branch 'openjpa/trunk'
        [ https://svn.apache.org/r1533641 ]

        OPENJPA-2440 close connection after not using it anymore

        this prevents leaks like the one reported by rmannibucau.

        Show
        ASF subversion and git services added a comment - Commit 1533641 from Mark Struberg in branch 'openjpa/trunk' [ https://svn.apache.org/r1533641 ] OPENJPA-2440 close connection after not using it anymore this prevents leaks like the one reported by rmannibucau.

          People

          • Assignee:
            Mark Struberg
            Reporter:
            Romain Manni-Bucau
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development