Bug #47574 MySQL Cluster : Internal blob read buffer size calculation incorrect on scans
Submitted: 23 Sep 2009 23:30 Modified: 25 Sep 2009 6:57
Reporter: Frazer Clement Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S2 (Serious)
Version:mysql-5.1-telco-6.2 OS:Any
Assigned to: Frazer Clement CPU Architecture:Any

[23 Sep 2009 23:30] Frazer Clement
Description:
When reading blobs from the database, MySQLD :
 1) Determines the size of all Blob values in a row
 2) Makes sure that it's internal blobs buffer is large enough to store them all, reallocating if necessary
 3) Reads the blob data into the blobs buffer

When scanning a table containing blobs, step 1) which determines the size of the Blob values in a row behaves incorrectly.  This can result in an overallocation of blobs buffer space.  In extreme cases there may not be enough system memory to allocate the (incorrectly over-large) blobs buffer.  In less extreme cases, performance can suffer.

How to repeat:
Create table containing n rows, each with 1 blob of m bytes.
-> Maximum blobs buffer required to store a row should be m bytes.

Scan table, while monitoring the size of the blobs buffer

Verify that the blobs buffer is oversized.

Suggested fix:
Ensure that per-row size accumulator is reset properly.
[24 Sep 2009 15:17] Frazer Clement
Commit patch (wrong bug# put into commit comment)

A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/84515

3005 Frazer Clement	2009-09-24
      Bug#45754 MySQL Cluster : Internal blob read buffer size calculation incorrect on
scans.  Ensure that required blob buffer size is reset for each row in scan
      modified:
        sql/ha_ndbcluster.cc
[24 Sep 2009 15:18] Frazer Clement
Pushed to 6.2.19, 6.3.27, 7.0.8, 7.1.0
[25 Sep 2009 6:57] Jon Stephens
Documented bugfix as follows, in the NDB-6.2.19, 6.3.27, and 7.0.8 changelogs:

        mysqld allocated an excessively large buffer for handling BLOB
        values due to overestimating their size. (For each row, enough
        space was allocated to accomomdate all BLOB values in the result
        set.) This could adversely affect performance when using tables
        containing BLOB or TEXT columns; in a few extreme cases, this
        could also cause the host system to run out of memory
        unexpectedly.

Closed.