Bug #75254 ha_ndbcluster usage of find_files leak memory into (unreleased) mem_root
Submitted: 18 Dec 2014 9:19 Modified: 15 May 2015 9:41
Reporter: Magnus Blåudd Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S3 (Non-critical)
Version:7.4.3 OS:Any
Assigned to: CPU Architecture:Any

[18 Dec 2014 9:19] Magnus Blåudd
Description:
When using find_file() to get a list of tables or databases the memory for the list is allocated in the mem_root of THD. The intention is that such mem_root should be freed at end of statement. However neither ndb_binlog_thread or ndb_util_thread really releases the mem_root. Well, there might be that this memory _is_ released by the mem_root fiddling in Ndb_binlog_thread, but that has to be verified.

There are two cases:

1) Ndb_util_thread calls:
 - ndb_binlog_setup()
     clean_away_stray_files()
       find_files(db_list)
         for each db in db_list
           find_files(table_list)
 - ^this may be called repeatedly during cluster reconnect.

2) Ndb_binlog_thread calls:
 - Ndb_schema_event_handler::handle_drop_db()
     check_if_local_tables_in_db()
       find_files(table_list)
 - this only runs on the schema dist participant when another mysqld drops database.

How to repeat:
Manual code inspection

Suggested fix:
The ndb_util_thread should not need to use THD at all. See "WL#7578
 Refactor schema distribution code" and "WL#7647 Ndb_util_thread::get_commit_count()"

The ndb_binlog_thread we should verify that the existing "recreate mem_root after each epoch" works satisfactorily and I think we should visualize the THD::mem_root usage with a counter.
[15 May 2015 9:41] Jon Stephens
Documented fix in the NDB 7.5.0 changelog as follows:

    Memory allocated when obtaining a list of tables or databases
    was not freed afterward.
      
Closed.