From 8bc1632ea54624b6bdb4aac692147603e734e9c5 Mon Sep 17 00:00:00 2001 From: Kristian Nielsen Date: Mon, 20 Mar 2017 13:29:37 +0100 Subject: [PATCH] MDEV-12179: Per-engine mysql.gtid_slave_pos table Intermediate commit. Implement the command-line part of --gtid-pos-auto-engines. (The option is still not actually used for anything, this will be for a later commit). --- mysql-test/suite/rpl/r/rpl_mdev12179.result | 6 ++++ mysql-test/suite/rpl/t/rpl_mdev12179.test | 7 ++++- sql/mysqld.cc | 31 +++++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/rpl/r/rpl_mdev12179.result b/mysql-test/suite/rpl/r/rpl_mdev12179.result index 17ae00740467a..c7a791faeb649 100644 --- a/mysql-test/suite/rpl/r/rpl_mdev12179.result +++ b/mysql-test/suite/rpl/r/rpl_mdev12179.result @@ -64,6 +64,12 @@ a 1 2 3 +SELECT @@gtid_pos_auto_engines; +@@gtid_pos_auto_engines +InnoDB,MyISAM +include/stop_slave.inc +SET GLOBAL gtid_pos_auto_engines=""; +include/start_slave.inc SET sql_log_bin=0; DROP TABLE mysql.gtid_slave_pos_innodb; SET sql_log_bin=1; diff --git a/mysql-test/suite/rpl/t/rpl_mdev12179.test b/mysql-test/suite/rpl/t/rpl_mdev12179.test index a85195eb6b40c..a4b344de3f1f1 100644 --- a/mysql-test/suite/rpl/t/rpl_mdev12179.test +++ b/mysql-test/suite/rpl/t/rpl_mdev12179.test @@ -62,8 +62,9 @@ SELECT * FROM t1 ORDER BY a; --source include/save_master_gtid.inc # Let the slave mysqld server start again. +# As we are restarting, also take the opportunity to test --gtid-pos-auto-engines --append_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect -restart: --skip-slave-start=0 +restart: --skip-slave-start=0 --gtid-pos-auto-engines=innodb,myisam EOF --connection server_2 @@ -73,6 +74,10 @@ EOF --source include/sync_with_master_gtid.inc SELECT * FROM t1 ORDER BY a; +SELECT @@gtid_pos_auto_engines; +--source include/stop_slave.inc +SET GLOBAL gtid_pos_auto_engines=""; +--source include/start_slave.inc --connection server_2 SET sql_log_bin=0; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 3c3acdf603048..e43b074a018c8 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -4917,6 +4917,26 @@ static int init_default_storage_engine_impl(const char *opt_name, return 0; } + +static int +init_gtid_pos_auto_engines(void) +{ + plugin_ref *plugins; + + if (gtid_pos_auto_engines) + plugins= resolve_engine_list(gtid_pos_auto_engines, + strlen(gtid_pos_auto_engines)); + else + plugins= resolve_engine_list("", 0); + if (!plugins) + return 1; + mysql_mutex_lock(&LOCK_global_system_variables); + opt_gtid_pos_auto_plugins= plugins; + mysql_mutex_unlock(&LOCK_global_system_variables); + return 0; +} + + static int init_server_components() { DBUG_ENTER("init_server_components"); @@ -5354,6 +5374,9 @@ static int init_server_components() if (init_default_storage_engine(enforced_storage_engine, enforced_table_plugin)) unireg_abort(1); + if (init_gtid_pos_auto_engines()) + unireg_abort(1); + #ifdef USE_ARIA_FOR_TMP_TABLES if (!ha_storage_engine_is_enabled(maria_hton) && !opt_bootstrap) { @@ -7354,6 +7377,14 @@ struct my_option my_long_options[]= "Set up signals usable for debugging. Deprecated, use --debug-gdb instead.", &opt_debugging, &opt_debugging, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"gtid-pos-auto-engines", 0, + "List of engines for which to automatically create a " + "mysql.gtid_slave_pos_ENGINE table, if a transaction using that engine " + "is replicated. This can be used to avoid introducing cross-engine " + "transactions, if engines are used different from that used by table " + "mysql.gtid_slave_pos", + >id_pos_auto_engines, 0, 0, GET_STR, REQUIRED_ARG, + 0, 0, 0, 0, 0, 0 }, #ifdef HAVE_LARGE_PAGE_OPTION {"super-large-pages", 0, "Enable support for super large pages.", &opt_super_large_pages, &opt_super_large_pages, 0,