Uploaded image for project: 'Derby'
  1. Derby
  2. DERBY-550 BLOB : java.lang.OutOfMemoryError with network JDBC driver (org.apache.derby.jdbc.ClientDriver)
  3. DERBY-1559

when receiving a single EXTDTA object representing a BLOB, the server do not need to read it into memory before inserting it into the DB

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 10.2.1.6, 10.2.2.0, 10.3.1.4
    • 10.2.2.0, 10.3.1.4
    • Network Server
    • None
    • Normal

    Description

      When streaming a BLOB from the Network Client to the Network Server, the Network server currently read all the data from the stream and put it into a byte array.
      The blob data is then inserted into the DB by using
      PreparedStatement.setBytes(..)

      and later

      PreparedStatement.execute()

      To avoid OutOfMemoryError if the size of the Blob is > than total memory in the VM, we could make the network server create a stream which reads data when doing PreparedStatement.execute(). The DB will then stream the BLOB data directly from the network inputstream into the disk.

      I intent to make a patch which does this if there is only one EXTDTA object (BLOB) sent from the client in the statement, as it will simplify the implementation. Later this can be improved further to include CLOBs, and possibly to include the cases where there are multiple EXTDTA objects.


      CLOBs are more complex, as there need to be some character encoding. This can be achieved by using a InputStreamReader, and use PreparedStatement.setCharacterStream(..). However the size of the stream is not necessarily the same as the size of the raw binary data, and to do this for CLOBs, I would need the embedded prepared statements to support the new setCharacterStream() overloads in JDBC4 (which do not include a length atribute)

      Multiple EXTDATA objects are also more complex, since one would need to have fully read the previous object ,before it is possible to read the next.

      Attachments

        1. DERBY-1559.diff
          18 kB
          Andreas Korneliussen
        2. DERBY-1559.stat
          0.3 kB
          Andreas Korneliussen
        3. DERBY-1559v2.diff
          18 kB
          Andreas Korneliussen
        4. DERBY-1559v3.diff
          18 kB
          Andreas Korneliussen
        5. DERBY-1559v4.diff
          18 kB
          Andreas Korneliussen
        6. DERBY-1559v5.diff
          18 kB
          Andreas Korneliussen
        7. DERBY-1559v6.diff
          18 kB
          Andreas Korneliussen
        8. serverMemoryUsage.xls
          2.60 MB
          Tomohito Nakayama

        Issue Links

          Activity

            People

              andreask Andreas Korneliussen
              andreask Andreas Korneliussen
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: