From f790499f11e20dab43b50245fd333ae2f5ebf7c9 Mon Sep 17 00:00:00 2001 From: Luqun Lou Date: Sat, 20 Mar 2021 09:51:47 -0700 Subject: [PATCH] allow install/uninstall plugin when enable_super_log_bin_read_only is enabled Summary: For secondaries, when enable_super_log_bin_read_only is on and read_only is on, currently it will forbid to install/uninstall plugin during run time. install/uninstall plugin doesn't generate event in binlog, although the thread thd contains OPTION_BIN_LOG flag due to log_slave_updates is on by default in secondaries. It should be safe to execute install/uninstall plugin. the change is to call set_skip_readonly_check() before install/uninstall plugin and call reset_skip_readonly_check()(for completeness) after install/uninstall plugin. BTW, mysql will always call reset_skip_readonly_check() for at the beginning of each statement. thus set_skip_readonly_check() won't affect other statement. ``` #0 THD::reset_skip_readonly_check (this=0x7fb5c1a0b000) at /home/luqun/mysql/mysql-8.0.20/sql/sql_class.h:1754 #1 0x0000000005a500e1 in THD::reset_for_next_command (this=0x7fb5c1a0b000) at /home/luqun/mysql/mysql-8.0.20/sql/sql_parse.cc:5892 #2 0x0000000005a517a5 in mysql_reset_thd_for_next_command (thd=0x7fb5c1a0b000) at /home/luqun/mysql/mysql-8.0.20/sql/sql_parse.cc:5817 #3 0x0000000005a50466 in mysql_parse (thd=0x7fb5c1a0b000, parser_state=0x7fb5f6bb4560, last_timer=0x7fb5f6bb39b0) at /home/luqun/mysql/mysql-8.0.20/sql/sql_parse.cc:6056 #4 0x0000000005a4c7c9 in dispatch_command (thd=0x7fb5c1a0b000, com_data=0x7fb5f6bb4d98, command=COM_QUERY) at /home/luqun/mysql/mysql-8.0.20/sql/sql_parse.cc:2222 #5 0x0000000005a4f991 in do_command (thd=0x7fb5c1a0b000) at /home/luqun/mysql/mysql-8.0.20/sql/sql_parse.cc:1556 #6 0x0000000005ccd4f1 in handle_connection (arg=0x7fb5cc85b740) at /home/luqun/mysql/mysql-8.0.20/sql/conn_handler/connection_handler_per_thread.cc:330 #7 0x00000000078eb95b in pfs_spawn_thread (arg=0x7fb5f8c89720) at /home/luqun/mysql/mysql-8.0.20/storage/perfschema/pfs.cc:2884 #8 0x00007fb5f957020c in start_thread (arg=0x7fb5f6bb6700) at pthread_create.c:479 #9 0x00007fb5f971881f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95 ``` Reviewed By: george-reynya Differential Revision: D27213990 --- sql/sql_plugin.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 036088bd6262..7361ac24d154 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -3672,14 +3672,22 @@ int unlock_plugin_data() { } bool Sql_cmd_install_plugin::execute(THD *thd) { + // install plugin doesn't generate any binlog event + // Thus, it is safe to execute even in readonly + thd->set_skip_readonly_check(); bool st = mysql_install_plugin(thd, m_comment, &m_ident); + thd->reset_skip_readonly_check(); if (!st) my_ok(thd); mysql_audit_release(thd); return st; } bool Sql_cmd_uninstall_plugin::execute(THD *thd) { + // uninstall plugin doesn't generate any binlog event + // Thus, it is safe to execute even in readonly + thd->set_skip_readonly_check(); bool st = mysql_uninstall_plugin(thd, m_comment); + thd->reset_skip_readonly_check(); if (!st) my_ok(thd); return st; }