[Commits] 38e141e: MDEV-11152: wsrep_replicate_myisam: SELECT gets replicated using TO

Nirbhay Choubey nirbhay at mariadb.com
Wed Oct 26 20:19:01 EEST 2016


revision-id: 38e141e0e5bde6ffed37ba21c044dda56adbfd3d (mariadb-10.1.18-7-g38e141e)
parent(s): 6593f1bff69a36858ec13a6ec2073f484d22b1aa
author: Nirbhay Choubey
committer: Nirbhay Choubey
timestamp: 2016-10-26 13:19:00 -0400
message:

MDEV-11152: wsrep_replicate_myisam: SELECT gets replicated using TO

Fixed the 'wsrep_replicate_myisam' check to allow only limited
set of commands. Added a debug assert to discover such cases.

---
 .../galera/r/galera_var_replicate_myisam_on.result |  9 ++++++++
 .../galera/t/galera_var_replicate_myisam_on.test   | 10 +++++++++
 sql/sql_base.cc                                    | 24 ++++++++++++++--------
 sql/sql_parse.cc                                   |  4 ++++
 4 files changed, 39 insertions(+), 8 deletions(-)

diff --git a/mysql-test/suite/galera/r/galera_var_replicate_myisam_on.result b/mysql-test/suite/galera/r/galera_var_replicate_myisam_on.result
index 73a0576..22ba4ca8 100644
--- a/mysql-test/suite/galera/r/galera_var_replicate_myisam_on.result
+++ b/mysql-test/suite/galera/r/galera_var_replicate_myisam_on.result
@@ -74,5 +74,14 @@ ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
 COMMIT;
 DROP TABLE t1;
 DROP TABLE t2;
+#
+# MDEV-11152: wsrep_replicate_myisam: SELECT gets replicated using TO
+#
+CREATE TABLE t1 (i INT) ENGINE=INNODB;
+INSERT INTO t1 VALUES(1);
+SELECT * FROM t1;
+i
+1
+DROP TABLE t1;
 SET GLOBAL wsrep_replicate_myisam = 0;
 SET GLOBAL wsrep_replicate_myisam = 0;
diff --git a/mysql-test/suite/galera/t/galera_var_replicate_myisam_on.test b/mysql-test/suite/galera/t/galera_var_replicate_myisam_on.test
index 9cb0edf..90c786f 100644
--- a/mysql-test/suite/galera/t/galera_var_replicate_myisam_on.test
+++ b/mysql-test/suite/galera/t/galera_var_replicate_myisam_on.test
@@ -132,6 +132,16 @@ COMMIT;
 DROP TABLE t1;
 DROP TABLE t2;
 
+--echo #
+--echo # MDEV-11152: wsrep_replicate_myisam: SELECT gets replicated using TO
+--echo #
+--connection node_1
+CREATE TABLE t1 (i INT) ENGINE=INNODB;
+INSERT INTO t1 VALUES(1);
+# This command should not get replicated.
+SELECT * FROM t1;
+DROP TABLE t1;
+
 --connection node_1
 --eval SET GLOBAL wsrep_replicate_myisam = $wsrep_replicate_myisam_orig
 
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index f04bece..e3f755b 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -4731,14 +4731,22 @@ bool open_tables(THD *thd, const DDL_options_st &options,
     }
   }
 
-  if (WSREP_ON                                 &&
-      wsrep_replicate_myisam                   &&
-      (*start)                                 &&
-      (*start)->table                          &&
-      (*start)->table->file->ht == myisam_hton &&
-      !is_stat_table((*start)->db, (*start)->alias) &&
-      sqlcom_can_generate_row_events(thd)      &&
-      thd->get_command() != COM_STMT_PREPARE)
+  if (WSREP_ON                                         &&
+      wsrep_replicate_myisam                           &&
+      (*start)                                         &&
+      (*start)->table                                  &&
+      (*start)->table->file->ht == myisam_hton         &&
+      wsrep_thd_exec_mode(thd) == LOCAL_STATE          &&
+      !is_stat_table((*start)->db, (*start)->alias)    &&
+      thd->get_command() != COM_STMT_PREPARE           &&
+      ((thd->lex->sql_command == SQLCOM_INSERT         ||
+        thd->lex->sql_command == SQLCOM_INSERT_SELECT  ||
+        thd->lex->sql_command == SQLCOM_REPLACE        ||
+        thd->lex->sql_command == SQLCOM_REPLACE_SELECT ||
+        thd->lex->sql_command == SQLCOM_UPDATE         ||
+        thd->lex->sql_command == SQLCOM_UPDATE_MULTI   ||
+        thd->lex->sql_command == SQLCOM_LOAD           ||
+        thd->lex->sql_command == SQLCOM_DELETE)))
   {
     WSREP_TO_ISOLATION_BEGIN(NULL, NULL, (*start));
   }
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index a15f3da..96c73d6 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -2941,6 +2941,10 @@ mysql_execute_command(THD *thd)
   case SQLCOM_SHOW_STORAGE_ENGINES:
   case SQLCOM_SHOW_PROFILE:
   {
+#ifdef WITH_WSREP
+    DBUG_ASSERT(thd->wsrep_exec_mode != REPL_RECV);
+#endif /* WITH_WSREP */
+
     thd->status_var.last_query_cost= 0.0;
 
     /*


More information about the commits mailing list