Bug #81046 ha_ndbcluster::open_indexes memory leak
Submitted: 12 Apr 2016 9:57 Modified: 2 May 2016 16:33
Reporter: Magnus Blåudd Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S2 (Serious)
Version:7.5.2 OS:Any
Assigned to: CPU Architecture:Any

[12 Apr 2016 9:57] Magnus Blåudd
Description:
Memory leak occurs when running 7.5 in valgrind. The memory leak is detected by valgrind  but not presented until all mysqld's are restarted before the ndb_startup test, thus it looks like it's ndb_startup who fails but that is not true.

This is the valgrind problem description:

==30280== 
==30280== 240 bytes in 1 blocks are definitely lost in loss record 1 of 6
==30280==    at 0x4C2B9B4: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==30280==    by 0x1E7E2DC: NdbDictionaryImpl::createRecordInternal(NdbTableImpl const*, NdbDictionary::RecordSpecification const*, unsigned int, unsigned int, unsigned int, bool) (NdbDictionaryImpl.cpp:7675)
==30280==    by 0x1E7EAE1: NdbDictionaryImpl::createRecord(NdbTableImpl const*, NdbDictionary::RecordSpecification const*, unsigned int, unsigned int, unsigned int, bool) (NdbDictionaryImpl.cpp:7923)
==30280==    by 0x1E5CD8E: NdbDictionary::Dictionary::createRecord(NdbDictionary::Table const*, NdbDictionary::RecordSpecification const*, unsigned int, unsigned int, unsigned int) (NdbDictionary.cpp:2810)
==30280==    by 0x1D5DB2B: ha_ndbcluster::add_index_ndb_record(NdbDictionary::Dictionary*, st_key*, unsigned int) (ha_ndbcluster.cc:2621)
==30280==    by 0x1D5D172: ha_ndbcluster::add_index_handle(THD*, NdbDictionary::Dictionary*, st_key*, char const*, unsigned int) (ha_ndbcluster.cc:2439)
==30280==    by 0x1D5DF5A: ha_ndbcluster::open_indexes(THD*, Ndb*, TABLE*, bool) (ha_ndbcluster.cc:2689)
==30280==    by 0x1D5C474: ha_ndbcluster::get_metadata(THD*, char const*) (ha_ndbcluster.cc:2208)
==30280==    by 0x1D79B56: ha_ndbcluster::open(char const*, int, unsigned int) (ha_ndbcluster.cc:12623)
==30280==    by 0xF7489C: handler::ha_open(TABLE*, char const*, int, int) (handler.cc:2629)
==30280==    by 0x166DC4B: open_table_from_share(THD*, TABLE_SHARE*, char const*, unsigned int, unsigned int, unsigned int, TABLE*, bool) (table.cc:3311)
==30280==    by 0x14F8B04: open_table(THD*, TABLE_LIST*, Open_table_context*) (sql_base.cc:3473)
==30280==    by 0x14FB36F: open_and_process_table(THD*, LEX*, TABLE_LIST*, unsigned int*, unsigned int, Prelocking_strategy*, bool, Open_table_context*) (sql_base.cc:5052)
==30280==    by 0x14FC411: open_tables(THD*, TABLE_LIST**, unsigned int*, unsigned int, Prelocking_strategy*) (sql_base.cc:5663)
==30280==    by 0x1614485: mysql_alter_table(THD*, char const*, char const*, st_ha_create_information*, TABLE_LIST*, Alter_info*) (sql_table.cc:8910)
==30280==    by 0x1791F72: Sql_cmd_alter_table::execute(THD*) (sql_alter.cc:316)
==30280==

How to repeat:
Reproducible in PB2 for 7.5 when running in valgrind.

./mtr --suite=ndb --valgrind

Check  mysql-test/var/log/mysqld.1.1.err

Suggested fix:
Find memory leak and deallocate to allocated memory.
[2 May 2016 16:33] Jon Stephens
DOcumented fix as follows in the NDB 7.5.2 changelog:

    Stopped a memory leak that occurred when an error was raised in
    ha_ndbcluster::get_metadata() or one of the functions which this
    method calls.

Closed.