Commit 7e08dd85 authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

MDEV-16264 prerequisite patch, ha_preshutdown.

This is a prerequisite patch required to remove Innodb's
thd_destructor_proxy thread.

The patch implement pre-shutdown functionality for handlers.

A storage engine might need to perform some work after all user
connections are shut down, but before killing off the plugins.

The reason is that an SE could still be using some of the
server infrastructure. In case of Innodb this would be purge threads,
that call into the server to calculate results of virtual function,
acquire MDL locks on tables, or possibly also use the audit plugins.
parent e7549917
......@@ -868,6 +868,33 @@ void ha_end_backup()
}
/*
Inform plugin of the server shutdown.
Called after all connections are down.
Under some circumstances, storage engine might need to
so some work, before deinit() can be safely called.
(an example is Innodb purge that might call into server
to calculate virtual columns, which might potentially also
invoke other plugins, such as audit
*/
static my_bool plugin_pre_shutdown(THD *, plugin_ref plugin, void *)
{
handlerton *hton= plugin_hton(plugin);
if (hton->pre_shutdown)
hton->pre_shutdown();
return FALSE;
}
void ha_pre_shutdown()
{
plugin_foreach_with_mask(0, plugin_pre_shutdown,
MYSQL_STORAGE_ENGINE_PLUGIN,
PLUGIN_IS_DELETED | PLUGIN_IS_READY, 0);
}
/* ========================================================================
======================= TRANSACTIONS ===================================*/
......
......@@ -1656,6 +1656,9 @@ struct handlerton
/* backup */
void (*prepare_for_backup)(void);
void (*end_backup)(void);
/* Server shutdown early notification.*/
void (*pre_shutdown)(void);
};
......@@ -4909,6 +4912,7 @@ int ha_delete_table(THD *thd, handlerton *db_type, const char *path,
const LEX_CSTRING *db, const LEX_CSTRING *alias, bool generate_warning);
void ha_prepare_for_backup();
void ha_end_backup();
void ha_pre_shutdown();
/* statistics and info */
bool ha_show_status(THD *thd, handlerton *db_type, enum ha_stat_type stat);
......
......@@ -5743,7 +5743,7 @@ int mysqld_main(int argc, char **argv)
#endif
close_connections();
ha_pre_shutdown();
clean_up(1);
sd_notify(0, "STATUS=MariaDB server is down");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment