#At file:///home/frazer/bzr/mysql-5.1-telco-6.2/
3004 Frazer Clement 2009-09-24
Bug#47573 MySQL Cluster : Internal blob read buffer not always freed correctly. Fix buffer release code and rename some vars to aid understanding
modified:
sql/ha_ndbcluster.cc
sql/ha_ndbcluster.h
=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc 2009-09-24 14:10:29 +0000
+++ b/sql/ha_ndbcluster.cc 2009-09-24 14:22:10 +0000
@@ -703,8 +703,8 @@ int g_get_ndb_blobs_value(NdbBlob *ndb_b
if (ndb_blob->getLength(len64) != 0)
ERR_RETURN(ndb_blob->getNdbError());
/* Align to Uint64. */
- ha->m_blob_total_size+= (len64 + 7) & ~((Uint64)7);
- if (ha->m_blob_total_size > 0xffffffff)
+ ha->m_blobs_row_total_size+= (len64 + 7) & ~((Uint64)7);
+ if (ha->m_blobs_row_total_size > 0xffffffff)
{
DBUG_ASSERT(FALSE);
DBUG_RETURN(-1);
@@ -716,24 +716,26 @@ int g_get_ndb_blobs_value(NdbBlob *ndb_b
Wait until all blobs are active with reading, so we can allocate
and use a common buffer containing all.
*/
- if (ha->m_blob_counter < ha->m_blob_expected_count)
+ if (ha->m_blob_counter < ha->m_blob_expected_count_per_row)
DBUG_RETURN(0);
+
+ /* Reset blob counter for next row (scan scenario) */
ha->m_blob_counter= 0;
- /* Re-allocate bigger blob buffer if necessary. */
- if (ha->m_blob_total_size > ha->m_blobs_buffer_size)
+ /* Re-allocate bigger blob buffer for this row if necessary. */
+ if (ha->m_blobs_row_total_size > ha->m_blobs_buffer_size)
{
my_free(ha->m_blobs_buffer, MYF(MY_ALLOW_ZERO_PTR));
DBUG_PRINT("info", ("allocate blobs buffer size %u",
- (uint32)(ha->m_blob_total_size)));
+ (uint32)(ha->m_blobs_row_total_size)));
ha->m_blobs_buffer=
- (uchar*) my_malloc(ha->m_blob_total_size, MYF(MY_WME));
+ (uchar*) my_malloc(ha->m_blobs_row_total_size, MYF(MY_WME));
if (ha->m_blobs_buffer == NULL)
{
ha->m_blobs_buffer_size= 0;
DBUG_RETURN(-1);
}
- ha->m_blobs_buffer_size= ha->m_blob_total_size;
+ ha->m_blobs_buffer_size= ha->m_blobs_row_total_size;
}
/*
@@ -825,9 +827,9 @@ ha_ndbcluster::get_blob_values(const Ndb
DBUG_ENTER("ha_ndbcluster::get_blob_values");
m_blob_counter= 0;
- m_blob_expected_count= 0;
+ m_blob_expected_count_per_row= 0;
m_blob_destination_record= dst_record;
- m_blob_total_size= 0;
+ m_blobs_row_total_size= 0;
for (i= 0; i < table_share->fields; i++)
{
@@ -842,7 +844,7 @@ ha_ndbcluster::get_blob_values(const Ndb
if ((ndb_blob= ndb_op->getBlobHandle(i)) == NULL ||
ndb_blob->setActiveHook(g_get_ndb_blobs_value, this) != 0)
DBUG_RETURN(1);
- m_blob_expected_count++;
+ m_blob_expected_count_per_row++;
}
else
ndb_blob= NULL;
@@ -1034,12 +1036,12 @@ bool ha_ndbcluster::uses_blob_value(cons
void ha_ndbcluster::release_blobs_buffer()
{
DBUG_ENTER("releaseBlobsBuffer");
- if (m_blob_total_size > 0)
+ if (m_blobs_buffer_size > 0)
{
- DBUG_PRINT("info", ("Deleting blobs buffer, size %llu", m_blob_total_size));
+ DBUG_PRINT("info", ("Deleting blobs buffer, size %u", m_blobs_buffer_size));
my_free(m_blobs_buffer, MYF(MY_ALLOW_ZERO_PTR));
m_blobs_buffer= 0;
- m_blob_total_size= 0;
+ m_blobs_row_total_size= 0;
m_blobs_buffer_size= 0;
}
DBUG_VOID_RETURN;
@@ -6645,7 +6647,7 @@ ha_ndbcluster::ha_ndbcluster(handlerton
m_update_cannot_batch(FALSE),
m_skip_auto_increment(TRUE),
m_blobs_pending(0),
- m_blob_total_size(0),
+ m_blobs_row_total_size(0),
m_blobs_buffer(0),
m_blobs_buffer_size(0),
m_dupkey((uint) -1),
=== modified file 'sql/ha_ndbcluster.h'
--- a/sql/ha_ndbcluster.h 2009-09-08 11:02:48 +0000
+++ b/sql/ha_ndbcluster.h 2009-09-24 14:22:10 +0000
@@ -709,9 +709,9 @@ private:
/* State for setActiveHook() callback for reading blob data. */
uint m_blob_counter;
- uint m_blob_expected_count;
+ uint m_blob_expected_count_per_row;
uchar *m_blob_destination_record;
- Uint64 m_blob_total_size;
+ Uint64 m_blobs_row_total_size; /* Bytes needed for all blobs in current row */
// memory for blobs in one tuple
uchar *m_blobs_buffer;
| Thread |
|---|
| • bzr commit into mysql-5.1-telco-6.2 branch (frazer:3004) Bug#47573 | Frazer Clement | 24 Sep |