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


    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s:
    • Fix Version/s: None
    • Component/s: Network Client
    • Urgency:


      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); }

      // I'm a sloppy java programmer


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

          Issue Links



              • Assignee:
                kmarsden Kathey Marsden
              • Votes:
                1 Vote for this issue
                2 Start watching this issue


                • Created: