1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Safe session_track_system_variables snapshot

When enabling system variables tracker, make a copy of
global_system_variables.session_track_system_variables
under LOCK_global_system_variables. This protects from concurrent variable
updates and potential freed memory access, as well as from variable
reconstruction (which was previously protected by LOCK_plugin).

We can also use this copy as a session variable pointer, so that we don't
have to allocate memory and reconstruct it every time it is referenced.

For this very reason we don't need buffer_length stuff anymore.

As well as don't we need to take LOCK_plugin early in ::enable().
Unified ::parse_var_list() to acquire LOCK_plugin unconditionally.
For no apparent reason it wasn't previously acquired for global
variable update.

Part of MDEV-14984 - regression in connect performance
This commit is contained in:
Sergey Vojtovich
2019-03-19 20:04:10 +04:00
parent 554ac6f393
commit 1b5cf2f7e7
4 changed files with 65 additions and 72 deletions

View File

@ -3149,6 +3149,11 @@ void plugin_thdvar_init(THD *thd)
thd->variables.enforced_table_plugin= NULL;
cleanup_variables(&thd->variables);
/* This and all other variable cleanups are here for COM_CHANGE_USER :( */
#ifndef EMBEDDED_LIBRARY
thd->session_tracker.sysvars.deinit(thd);
#endif
thd->variables= global_system_variables;
/* we are going to allocate these lazily */
@ -3170,6 +3175,9 @@ void plugin_thdvar_init(THD *thd)
intern_plugin_unlock(NULL, old_enforced_table_plugin);
mysql_mutex_unlock(&LOCK_plugin);
#ifndef EMBEDDED_LIBRARY
thd->session_tracker.sysvars.init(thd);
#endif
DBUG_VOID_RETURN;
}
@ -3235,6 +3243,10 @@ void plugin_thdvar_cleanup(THD *thd)
plugin_ref *list;
DBUG_ENTER("plugin_thdvar_cleanup");
#ifndef EMBEDDED_LIBRARY
thd->session_tracker.sysvars.deinit(thd);
#endif
mysql_mutex_lock(&LOCK_plugin);
unlock_variables(thd, &thd->variables);