Comment 5 for bug 1620152

Revision history for this message
Sergei Glushchenko (sergei.glushchenko) wrote :

Looks like thd_local never gets released

mysql> SELECT event_name, sys.format_bytes(SUM(current_alloc)) AS current_alloc FROM sys.x$memory_global_by_current_bytes WHERE event_name like "%audit%" GROUP BY event_name ORDER BY SUM(current_alloc) DESC;
+------------------------------------------+---------------+
| event_name | current_alloc |
+------------------------------------------+---------------+
| memory/audit_log/audit_log_thd_local | 932.47 KiB |
| memory/audit_log/audit_log_query_stack | 211.12 KiB |
| memory/audit_log/audit_log_logger_handle | 712 bytes |
| memory/audit_log/audit_log_commands | 640 bytes |
| memory/audit_log/audit_log_databases | 640 bytes |
| memory/audit_log/audit_log_accounts | 640 bytes |
| memory/audit_log/audit_log_handler | 88 bytes |
+------------------------------------------+---------------+
7 rows in set (0.01 sec)

and few minutes later

mysql> SELECT event_name, sys.format_bytes(SUM(current_alloc)) AS current_alloc FROM sys.x$memory_global_by_current_bytes WHERE event_name like "%audit%" GROUP BY event_name ORDER BY SUM(current_alloc) DESC;
+------------------------------------------+---------------+
| event_name | current_alloc |
+------------------------------------------+---------------+
| memory/audit_log/audit_log_thd_local | 2.45 MiB |
| memory/audit_log/audit_log_query_stack | 567.84 KiB |
| memory/audit_log/audit_log_logger_handle | 712 bytes |
| memory/audit_log/audit_log_commands | 640 bytes |
| memory/audit_log/audit_log_databases | 640 bytes |
| memory/audit_log/audit_log_accounts | 640 bytes |
| memory/audit_log/audit_log_handler | 88 bytes |
+------------------------------------------+---------------+
7 rows in set (0.01 sec)

dynamic_variables_allocs is NULL:

* thread #26: tid = 0x2d4922, 0x000000010a5c50c3 mysqld`plugin_var_memalloc_free(vars=0x00007f87721509e0) + 35 at sql_plugin.cc:3322, stop reason = breakpoint 2.1
    frame #0: 0x000000010a5c50c3 mysqld`plugin_var_memalloc_free(vars=0x00007f87721509e0) + 35 at sql_plugin.cc:3322
   3319 static void plugin_var_memalloc_free(struct system_variables *vars)
   3320 {
   3321 LIST *next, *root;
-> 3322 DBUG_ENTER("plugin_var_memalloc_free");
   3323 for (root= vars->dynamic_variables_allocs; root; root= next)
   3324 {
   3325 next= root->next;
(lldb) p vars->dynamic_variables_allocs
(LIST *) $0 = 0x0000000000000000

variables added to that list in `plugin_var_memalloc_session_update` if `value` is not NULL, but it is NULL... looking further

* thread #26: tid = 0x2d4922, 0x000000010a5c32c3 mysqld`plugin_var_memalloc_session_update(thd=0x00007f87718a1c00, var=0x0000000000000000, dest=0x00007f87734b8580, value=0x0000000000000000) + 51 at sql_plugin.cc:3276, stop reason = breakpoint 3.1
    frame #0: 0x000000010a5c32c3 mysqld`plugin_var_memalloc_session_update(thd=0x00007f87718a1c00, var=0x0000000000000000, dest=0x00007f87734b8580, value=0x0000000000000000) + 51 at sql_plugin.cc:3276
   3273 char **dest, const char *value)
   3274
   3275 {
-> 3276 LIST *old_element= NULL;
   3277 struct system_variables *vars= &thd->variables;
   3278 DBUG_ENTER("plugin_var_memalloc_session_update");