Derby
  1. Derby
  2. DERBY-210

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

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 10.0.2.0
    • Fix Version/s: None
    • Component/s: Network Client
    • Urgency:
      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.

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

        Issue Links

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              Kathey Marsden
            • Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:

                Development