Uploaded image for project: 'Derby'
  1. Derby
  2. DERBY-210

Network Server will leak prepared statements if not explicitly closed by the user until the connection is closed

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 10.0.2.0
    • None
    • Network Client
    • Normal

    Description

      Network server will not garbage collect prepared statements that are not explicitly closed by the user. So a loop like this will leak.

      ...
      PreparedStatement ps;

      for (int i = 0 ; i < numPs; i++)
      {

      ps = conn.prepareStatement(selTabSql);
      rs =ps.executeQuery();

      while (rs.next())

      { rs.getString(1); }

      rs.close();
      // I'm a sloppy java programmer
      //ps.close();

      }

      To reproduce run the attached program
      java derbyStress

      Both client and server will grow until the connection is closed.

      It is likely that the fix for this will have to be in the client. The client does not send protocol to close the prepared statement, but rather reuses the PKGNAMCSN on the PRPSQLSTT request once the prepared statement has been closed. This is how the server knows to close the old statement and create a new one.

      Attachments

        1. StatementStress.java
          17 kB
          John Embretsen
        2. runtimeinfo_DOTS-OOME.txt
          32 kB
          John Embretsen
        3. DOTS_ATCJ2_Derby-withPatch.png
          7 kB
          John Embretsen
        4. DOTS_ATCJ2_Derby-noPatch.png
          6 kB
          John Embretsen
        5. derbyStress.java
          12 kB
          Katherine Marsden
        6. derby-210-v2-draft.status
          0.8 kB
          Deepa
        7. derby-210-v2-draft.diff
          19 kB
          Deepa
        8. derby-210-patch5-v1.status
          0.4 kB
          Deepa
        9. derby-210-patch5-v1.diff
          10 kB
          Deepa
        10. derby-210-patch4-v3.status
          0.1 kB
          Deepa
        11. derby-210-patch4-v3.diff
          7 kB
          Deepa
        12. derby-210-patch4-v2.status
          0.1 kB
          Deepa
        13. derby-210-patch4-v2.diff
          6 kB
          Deepa
        14. derby-210-patch3.diff
          0.8 kB
          Deepa
        15. derby-210-patch2.status
          0.6 kB
          Deepa
        16. derby-210-patch2.diff
          8 kB
          Deepa
        17. derby-210-patch1.diff
          2 kB
          Deepa

        Issue Links

          Activity

            People

              Unassigned Unassigned
              kmarsden Katherine Marsden
              Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: