[Commits] 8ffded0: MDEV-9312: storage engine not enforced during galera cluster replication

Nirbhay Choubey nirbhay at mariadb.com
Sat Sep 24 07:06:14 EEST 2016


revision-id: 8ffded0a78c0a4912b32acac4c3f58f04c3bcd87 (mariadb-10.1.17-22-g8ffded0)
parent(s): 6a6b253a6ecbd4d3dd254044d12ec64475453275
author: Nirbhay Choubey
committer: Nirbhay Choubey
timestamp: 2016-09-24 00:06:09 -0400
message:

MDEV-9312: storage engine not enforced during galera cluster replication

Perform a post initialization of plugin-related variables
of wsrep threads after their global counterparts have been
initialized.

---
 .../suite/galera/r/enforce_storage_engine2.result  | 24 ++++++++++++++++++++++
 .../suite/galera/t/enforce_storage_engine2.opt     |  2 ++
 .../suite/galera/t/enforce_storage_engine2.test    | 20 ++++++++++++++++++
 sql/mysqld.cc                                      |  3 +++
 sql/sql_plugin.cc                                  |  9 +++++++-
 sql/wsrep_mysqld.h                                 |  2 ++
 sql/wsrep_thd.cc                                   | 19 +++++++++++++++++
 7 files changed, 78 insertions(+), 1 deletion(-)

diff --git a/mysql-test/suite/galera/r/enforce_storage_engine2.result b/mysql-test/suite/galera/r/enforce_storage_engine2.result
new file mode 100644
index 0000000..053c37d
--- /dev/null
+++ b/mysql-test/suite/galera/r/enforce_storage_engine2.result
@@ -0,0 +1,24 @@
+#
+# MDEV-9312: storage engine not enforced during galera cluster
+# replication
+#
+CREATE TABLE t1(i INT) ENGINE=INNODB;
+CREATE TABLE t2(i INT) ENGINE=MYISAM;
+Warnings:
+Note	1266	Using storage engine InnoDB for table 't2'
+SHOW TABLES;
+Tables_in_test
+t1
+t2
+SHOW CREATE TABLE t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `i` int(11) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+SHOW CREATE TABLE t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `i` int(11) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+DROP TABLE t1, t2;
+# End of tests
diff --git a/mysql-test/suite/galera/t/enforce_storage_engine2.opt b/mysql-test/suite/galera/t/enforce_storage_engine2.opt
new file mode 100644
index 0000000..03f7dc5
--- /dev/null
+++ b/mysql-test/suite/galera/t/enforce_storage_engine2.opt
@@ -0,0 +1,2 @@
+--enforce_storage_engine=innodb --sql_mode=''
+
diff --git a/mysql-test/suite/galera/t/enforce_storage_engine2.test b/mysql-test/suite/galera/t/enforce_storage_engine2.test
new file mode 100644
index 0000000..7a822bc
--- /dev/null
+++ b/mysql-test/suite/galera/t/enforce_storage_engine2.test
@@ -0,0 +1,20 @@
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+--echo #
+--echo # MDEV-9312: storage engine not enforced during galera cluster
+--echo # replication
+--echo #
+--connection node_1
+CREATE TABLE t1(i INT) ENGINE=INNODB;
+CREATE TABLE t2(i INT) ENGINE=MYISAM;
+
+--connection node_2
+SHOW TABLES;
+SHOW CREATE TABLE t1;
+SHOW CREATE TABLE t2;
+
+# Cleanup
+DROP TABLE t1, t2;
+
+--echo # End of tests
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index a71d6d1..8ddc986 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -5302,6 +5302,9 @@ static int init_server_components()
 #endif
 
 #ifdef WITH_WSREP
+  /* Post-initialize members of wsrep startup threads. */
+  wsrep_thd_post_init();
+
   if (WSREP_ON && !opt_bin_log)
   {
     wsrep_emulate_bin_log= 1;
diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc
index 60248f3..99b3311 100644
--- a/sql/sql_plugin.cc
+++ b/sql/sql_plugin.cc
@@ -3096,6 +3096,8 @@ static double *mysql_sys_var_double(THD* thd, int offset)
   return (double *) intern_sys_var_ptr(thd, offset, true);
 }
 
+extern my_bool plugins_are_initialized;
+
 void plugin_thdvar_init(THD *thd)
 {
   plugin_ref old_table_plugin= thd->variables.table_plugin;
@@ -3116,7 +3118,12 @@ void plugin_thdvar_init(THD *thd)
   thd->variables.dynamic_variables_size= 0;
   thd->variables.dynamic_variables_ptr= 0;
 
-  if (IF_WSREP((!WSREP(thd) || !thd->wsrep_applier),1))
+  /*
+    The following initializations are deferred for some wsrep system threads
+    created during startup as they could be created even before LOCK_plugin
+    and plugins are initialized.
+  */
+  if (IF_WSREP((plugins_are_initialized),1))
   {
     mysql_mutex_lock(&LOCK_plugin);
     thd->variables.table_plugin=
diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h
index 04ccc1a..9a33e99 100644
--- a/sql/wsrep_mysqld.h
+++ b/sql/wsrep_mysqld.h
@@ -315,6 +315,7 @@ bool wsrep_create_like_table(THD* thd, TABLE_LIST* table,
 	                     HA_CREATE_INFO *create_info);
 bool wsrep_node_is_donor();
 bool wsrep_node_is_synced();
+void wsrep_thd_post_init();
 
 #else /* WITH_WSREP */
 
@@ -345,6 +346,7 @@ bool wsrep_create_like_table(THD* thd, TABLE_LIST* table,
 #define wsrep_thr_init() do {} while(0)
 #define wsrep_thr_deinit() do {} while(0)
 #define wsrep_running_threads (0)
+#define wsrep_thd_post_init (0)
 
 #endif /* WITH_WSREP */
 #endif /* WSREP_MYSQLD_H */
diff --git a/sql/wsrep_thd.cc b/sql/wsrep_thd.cc
index cf69a4d..8a0d7d3 100644
--- a/sql/wsrep_thd.cc
+++ b/sql/wsrep_thd.cc
@@ -644,3 +644,22 @@ bool wsrep_thd_has_explicit_locks(THD *thd)
   assert(thd);
   return thd->mdl_context.has_explicit_locks();
 }
+
+/*
+  Initialize some of the members of wsrep threads after
+  certain components of the server are initialized.
+*/
+void wsrep_thd_post_init()
+{
+  THD *thd;
+  I_List_iterator<THD> it(threads);
+
+  while ((thd= it++))
+  {
+    if (thd->wsrep_applier)
+    {
+      plugin_thdvar_init(thd);
+    }
+  }
+  return;
+}


More information about the commits mailing list