[Commits] Rev 3900: MDEV-6924 : Server crashed on CREATE TABLE ... SELECT in lp:~maria-captains/maria/maria-10.0-galera

Nirbhay Choubey nirbhay at mariadb.com
Mon Nov 17 18:56:11 EET 2014


At lp:~maria-captains/maria/maria-10.0-galera

------------------------------------------------------------
revno: 3900
revision-id: nirbhay at mariadb.com-20141117165603-a5ukmap0ysscnq66
parent: nirbhay at mariadb.com-20141008173045-yu5qavlnnr2b97fd
committer: Nirbhay Choubey <nirbhay at mariadb.com>
branch nick: maria-10.0-galera_6924
timestamp: Mon 2014-11-17 11:56:03 -0500
message:
  MDEV-6924 : Server crashed on CREATE TABLE ... SELECT
    
  Do not allow server to start if binlog_format is set
  to a format other than ROW. Also restrict the change
  of GLOBAL/SESSION binlog_format value at runtime.
-------------- next part --------------
=== added file 'mysql-test/suite/galera/r/create.result'
--- a/mysql-test/suite/galera/r/create.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/galera/r/create.result	2014-11-17 16:56:03 +0000
@@ -0,0 +1,23 @@
+#
+# MDEV-6924 : Server crashed on CREATE TABLE ... SELECT
+#
+SET @wsrep_forced_binlog_format_saved=@@GLOBAL.wsrep_forced_binlog_format;
+SET @@GLOBAL.wsrep_forced_binlog_format=STATEMENT;
+SHOW VARIABLES LIKE '%log%bin%';
+Variable_name	Value
+log_bin	OFF
+log_bin_trust_function_creators	ON
+sql_log_bin	ON
+USE test;
+CREATE TABLE t1(i INT) ENGINE=INNODB;
+INSERT INTO t1 VALUES(1);
+CREATE TEMPORARY TABLE `t1_temp` AS SELECT * FROM `t1` WHERE i = 1;
+SELECT * FROM t1;
+i
+1
+SELECT * FROM t1_temp;
+i
+1
+DROP TABLE t1;
+SET @@GLOBAL.wsrep_forced_binlog_format=@wsrep_forced_binlog_format_saved;
+# End of tests

=== added file 'mysql-test/suite/galera/t/create.test'
--- a/mysql-test/suite/galera/t/create.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/galera/t/create.test	2014-11-17 16:56:03 +0000
@@ -0,0 +1,26 @@
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+--echo #
+--echo # MDEV-6924 : Server crashed on CREATE TABLE ... SELECT
+--echo #
+
+SET @wsrep_forced_binlog_format_saved=@@GLOBAL.wsrep_forced_binlog_format;
+SET @@GLOBAL.wsrep_forced_binlog_format=STATEMENT;
+
+# @@log_bin must be OFF
+SHOW VARIABLES LIKE '%log%bin%';
+
+USE test;
+CREATE TABLE t1(i INT) ENGINE=INNODB;
+INSERT INTO t1 VALUES(1);
+CREATE TEMPORARY TABLE `t1_temp` AS SELECT * FROM `t1` WHERE i = 1;
+SELECT * FROM t1;
+SELECT * FROM t1_temp;
+
+# Cleanup
+DROP TABLE t1;
+SET @@GLOBAL.wsrep_forced_binlog_format=@wsrep_forced_binlog_format_saved;
+
+--echo # End of tests
+

=== modified file 'mysql-test/suite/wsrep/r/binlog_format.result'
--- a/mysql-test/suite/wsrep/r/binlog_format.result	2014-03-27 12:17:24 +0000
+++ b/mysql-test/suite/wsrep/r/binlog_format.result	2014-11-17 16:56:03 +0000
@@ -1,5 +1,6 @@
 call mtr.add_suppression("WSREP: cannot get fake InnoDB transaction ID");
 call mtr.add_suppression("WSREP: Could not open saved state file for reading:.*");
+call mtr.add_suppression("WSREP: MariaDB Galera does not support binlog format.*");
 SHOW VARIABLES LIKE 'binlog_format';
 Variable_name	Value
 binlog_format	ROW
@@ -33,3 +34,18 @@
 DROP TABLE IF EXISTS test.t1;
 DROP TABLE IF EXISTS test.t2;
 DROP TABLE IF EXISTS test.t3;
+SET @@GLOBAL.binlog_format=STATEMENT;
+ERROR 42000: Variable 'binlog_format' can't be set to the value of 'STATEMENT'
+SHOW GLOBAL VARIABLES LIKE 'binlog_format';
+Variable_name	Value
+binlog_format	ROW
+SET @@GLOBAL.binlog_format=MIXED;
+ERROR 42000: Variable 'binlog_format' can't be set to the value of 'MIXED'
+SHOW GLOBAL VARIABLES LIKE 'binlog_format';
+Variable_name	Value
+binlog_format	ROW
+SET @@GLOBAL.binlog_format=ROW;
+SHOW GLOBAL VARIABLES LIKE 'binlog_format';
+Variable_name	Value
+binlog_format	ROW
+# End of test.

=== modified file 'mysql-test/suite/wsrep/t/binlog_format.test'
--- a/mysql-test/suite/wsrep/t/binlog_format.test	2014-09-09 23:19:12 +0000
+++ b/mysql-test/suite/wsrep/t/binlog_format.test	2014-11-17 16:56:03 +0000
@@ -5,6 +5,7 @@
 #
 call mtr.add_suppression("WSREP: cannot get fake InnoDB transaction ID");
 call mtr.add_suppression("WSREP: Could not open saved state file for reading:.*");
+call mtr.add_suppression("WSREP: MariaDB Galera does not support binlog format.*");
 
 SHOW VARIABLES LIKE 'binlog_format';
 -- error ER_WRONG_VALUE_FOR_VAR
@@ -25,3 +26,15 @@
 DROP TABLE IF EXISTS test.t2;
 DROP TABLE IF EXISTS test.t3;
 
+-- error ER_WRONG_VALUE_FOR_VAR
+SET @@GLOBAL.binlog_format=STATEMENT;
+SHOW GLOBAL VARIABLES LIKE 'binlog_format';
+
+-- error ER_WRONG_VALUE_FOR_VAR
+SET @@GLOBAL.binlog_format=MIXED;
+SHOW GLOBAL VARIABLES LIKE 'binlog_format';
+
+SET @@GLOBAL.binlog_format=ROW;
+SHOW GLOBAL VARIABLES LIKE 'binlog_format';
+
+--echo # End of test.

=== modified file 'mysql-test/suite/wsrep/t/pool_of_threads.test'
--- a/mysql-test/suite/wsrep/t/pool_of_threads.test	2014-03-27 20:22:57 +0000
+++ b/mysql-test/suite/wsrep/t/pool_of_threads.test	2014-11-17 16:56:03 +0000
@@ -1,4 +1,5 @@
 --source include/have_wsrep.inc
+--source include/have_binlog_format_row.inc
 
 --echo
 --echo #

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2014-09-30 22:06:15 +0000
+++ b/sql/mysqld.cc	2014-11-17 16:56:03 +0000
@@ -9631,6 +9631,15 @@
     global_system_variables.option_bits&= ~OPTION_BIG_SELECTS;
 
 #ifdef WITH_WSREP
+  if (!opt_bootstrap && WSREP_PROVIDER_EXISTS &&
+      global_system_variables.binlog_format != BINLOG_FORMAT_ROW) {
+
+    WSREP_ERROR ("Only binlog_format = 'ROW' is currently supported. "
+                 "Configured value: '%s'. Please adjust your configuration.",
+                 binlog_format_names[global_system_variables.binlog_format]);
+    return 1;
+  }
+
   if (global_system_variables.wsrep_causal_reads) {
       WSREP_WARN("option --wsrep-casual-reads is deprecated");
       if (!(global_system_variables.wsrep_sync_wait &

=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc	2014-09-29 00:43:56 +0000
+++ b/sql/sql_class.cc	2014-11-17 16:56:03 +0000
@@ -6590,6 +6590,16 @@
       The MYSQL_LOG::write() function will set the STMT_END_F flag and
       flush the pending rows event if necessary.
     */
+#ifdef WITH_WSREP
+    /*
+      Even though wsrep only supports ROW binary log format, a user can set
+      binlog format to STATEMENT (wsrep_forced_binlog_format). In which case
+      the control might reach here even when binary logging (--log-bin) is
+      not enabled. This is possible because wsrep patch partially enables
+      binary logging by setting wsrep_emulate_binlog.
+    */
+    if (mysql_bin_log.is_open())
+#endif /* WITH_WSREP */
     {
       Query_log_event qinfo(this, query_arg, query_len, is_trans, direct,
                             suppress_use, errcode);

=== modified file 'sql/sys_vars.cc'
--- a/sql/sys_vars.cc	2014-09-29 00:43:56 +0000
+++ b/sql/sys_vars.cc	2014-11-17 16:56:03 +0000
@@ -437,6 +437,24 @@
   if (check_has_super(self, thd, var))
     return true;
 
+#ifdef WITH_WSREP
+  /*
+    MariaDB Galera does not support STATEMENT or MIXED binlog format currently.
+  */
+  if (WSREP(thd) &&
+      var->save_result.ulonglong_value != BINLOG_FORMAT_ROW)
+  {
+    WSREP_ERROR("MariaDB Galera does not support binlog format: %s",
+                binlog_format_names[var->save_result.ulonglong_value]);
+
+    // Also push a warning because error message is general.
+    push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR,
+                        "MariaDB Galera does not support binlog format: %s",
+                        binlog_format_names[var->save_result.ulonglong_value]);
+    return true;
+  }
+#endif
+
   if (var->type == OPT_GLOBAL)
     return false;
 
@@ -465,26 +483,6 @@
          ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_BINLOG_FORMAT))
     return true;
 
-#ifdef WITH_WSREP
-  /* MariaDB Galera does not support STATEMENT or MIXED binlog
-  format currently */
-  if (WSREP(thd) &&
-     (var->save_result.ulonglong_value == BINLOG_FORMAT_STMT ||
-      var->save_result.ulonglong_value == BINLOG_FORMAT_MIXED))
-  {
-    WSREP_DEBUG("MariaDB Galera does not support binlog format : %s",
-                var->save_result.ulonglong_value == BINLOG_FORMAT_STMT ?
-                "STATEMENT" : "MIXED");
-    /* Push also warning, because error message is general */
-    push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
-                        ER_UNKNOWN_ERROR,
-                        "MariaDB Galera does not support binlog format: %s",
-                        var->save_result.ulonglong_value == BINLOG_FORMAT_STMT ?
-                        "STATEMENT" : "MIXED");
-    return true;
-  }
-#endif
-
   return false;
 }
 



More information about the commits mailing list