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.
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.