mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
Bug#17638477 UNINSTALL AND INSTALL SEMI-SYNC PLUGIN CAUSES SLAVES TO BREAK
Problem: Uninstallation of semi sync plugin causes replication to break. Analysis: A semisync enabled replication is mutual agreement between Master and Slave when the connection (I/O thread) is established. Once I/O thread is started and if semisync is enabled on both master and slave, master appends special magic header to events using semisync plugin functions and sends it to slave. And slave expects that each event will have that special magic header format and reads those bytes using semisync plugin functions. When semi sync replication is in use if users execute uninstallation of the plugin on master, slave gets confused while interpreting that event's content because it expects special magic header at the beginning of the event. Slave SQL thread will be stopped with "Missing magic number in the header" error. Similar problem will happen if uninstallation of the plugin happens on slave when semi sync replication is in in use. Master sends the events with magic header and slave does not know about the added magic header and thinks that it received a corrupted event. Hence slave SQL thread stops with "Found corrupted event" error. Fix: Uninstallation of semisync plugin will be blocked when semisync replication is in use and will throw 'ER_UNKNOWN_ERROR' error. To detect that semisync replication is in use, this patch uses semisync status variable values. > On Master, it checks for 'Rpl_semi_sync_master_status' to be OFF before allowing the uninstallation of rpl_semi_sync_master plugin. >> Rpl_semi_sync_master_status is OFF when >>> there is no dump thread running >>> there are no semisync slaves > On Slave, it checks for 'Rpl_semi_sync_slave_status' to be OFF before allowing the uninstallation of rpl_semi_sync_slave plugin. >> Rpl_semi_sync_slave_status is OFF when >>> there is no I/O thread running >>> replication is asynchronous replication.
This commit is contained in:
@@ -1930,6 +1930,49 @@ bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name)
|
||||
goto err;
|
||||
}
|
||||
|
||||
#ifdef HAVE_REPLICATION
|
||||
/* Block Uninstallation of semi_sync plugins (Master/Slave)
|
||||
when they are busy
|
||||
*/
|
||||
char buff[20];
|
||||
/*
|
||||
Master: If there are active semi sync slaves for this Master,
|
||||
then that means it is busy and rpl_semi_sync_master plugin
|
||||
cannot be uninstalled. To check whether the master
|
||||
has any semi sync slaves or not, check Rpl_semi_sync_master_cliens
|
||||
status variable value, if it is not 0, that means it is busy.
|
||||
*/
|
||||
if (!strcmp(name->str, "rpl_semi_sync_master") &&
|
||||
get_status_var(thd,
|
||||
plugin->plugin->status_vars,
|
||||
"Rpl_semi_sync_master_clients",buff) &&
|
||||
strcmp(buff,"0") )
|
||||
{
|
||||
sql_print_error("Plugin 'rpl_semi_sync_master' cannot be uninstalled now. "
|
||||
"Stop any active semisynchronous slaves of this master "
|
||||
"first.\n");
|
||||
my_error(ER_UNKNOWN_ERROR, MYF(0), name->str);
|
||||
goto err;
|
||||
}
|
||||
/* Slave: If there is semi sync enabled IO thread active on this Slave,
|
||||
then that means plugin is busy and rpl_semi_sync_slave plugin
|
||||
cannot be uninstalled. To check whether semi sync
|
||||
IO thread is active or not, check Rpl_semi_sync_slave_status status
|
||||
variable value, if it is ON, that means it is busy.
|
||||
*/
|
||||
if (!strcmp(name->str, "rpl_semi_sync_slave") &&
|
||||
get_status_var(thd, plugin->plugin->status_vars,
|
||||
"Rpl_semi_sync_slave_status", buff) &&
|
||||
!strcmp(buff,"ON") )
|
||||
{
|
||||
sql_print_error("Plugin 'rpl_semi_sync_slave' cannot be uninstalled now. "
|
||||
"Stop any active semisynchronous I/O threads on this slave "
|
||||
"first.\n");
|
||||
my_error(ER_UNKNOWN_ERROR, MYF(0), name->str);
|
||||
goto err;
|
||||
}
|
||||
#endif
|
||||
|
||||
plugin->state= PLUGIN_IS_DELETED;
|
||||
if (plugin->ref_count)
|
||||
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
|
||||
|
Reference in New Issue
Block a user