From 9379edb63d85bcb256a4e145827db9c4c76f15c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Mon, 2 Dec 2013 08:58:06 +0200 Subject: [PATCH] MDEV-4227: Galera server should stop crashing on setting binlog_format STATEMENT Analysis: Currently you can set binlog_format to STATEMENT or MIXED even when they are not really supported by galera. Fix: Produce an error message if binlog_format is set to STATEMENT or MIXED and wsrep_on = ON. Added a test case for this. --- mysql-test/include/have_wsrep.inc | 4 +++ mysql-test/r/have_wsrep.require | 2 ++ mysql-test/suite/wsrep/r/binlog_format.result | 33 +++++++++++++++++++ mysql-test/suite/wsrep/t/binlog_format.opt | 1 + mysql-test/suite/wsrep/t/binlog_format.test | 24 ++++++++++++++ sql/sys_vars.cc | 20 +++++++++++ 6 files changed, 84 insertions(+) create mode 100644 mysql-test/include/have_wsrep.inc create mode 100644 mysql-test/r/have_wsrep.require create mode 100644 mysql-test/suite/wsrep/r/binlog_format.result create mode 100644 mysql-test/suite/wsrep/t/binlog_format.opt create mode 100644 mysql-test/suite/wsrep/t/binlog_format.test diff --git a/mysql-test/include/have_wsrep.inc b/mysql-test/include/have_wsrep.inc new file mode 100644 index 00000000000..f8f7e7a82fc --- /dev/null +++ b/mysql-test/include/have_wsrep.inc @@ -0,0 +1,4 @@ +-- require r/have_wsrep.require +disable_query_log; +show variables like 'wsrep_on'; +enable_query_log; diff --git a/mysql-test/r/have_wsrep.require b/mysql-test/r/have_wsrep.require new file mode 100644 index 00000000000..af32ac7dca7 --- /dev/null +++ b/mysql-test/r/have_wsrep.require @@ -0,0 +1,2 @@ +Variable_name Value +wsrep_on ON diff --git a/mysql-test/suite/wsrep/r/binlog_format.result b/mysql-test/suite/wsrep/r/binlog_format.result new file mode 100644 index 00000000000..d87cd3bf1a8 --- /dev/null +++ b/mysql-test/suite/wsrep/r/binlog_format.result @@ -0,0 +1,33 @@ +SHOW VARIABLES LIKE 'binlog_format'; +Variable_name Value +binlog_format ROW +SET binlog_format=STATEMENT; +ERROR 42000: Variable 'binlog_format' can't be set to the value of 'STATEMENT' +SHOW WARNINGS; +Level Code Message +Warning 1105 MariaDB Galera does not support binlog format: STATEMENT +Error 1231 Variable 'binlog_format' can't be set to the value of 'STATEMENT' +SHOW VARIABLES LIKE 'binlog_format'; +Variable_name Value +binlog_format ROW +CREATE TABLE IF NOT EXISTS test.t1 AS SELECT * FROM information_schema.routines WHERE 1 = 0; +SET binlog_format=MIXED; +ERROR 42000: Variable 'binlog_format' can't be set to the value of 'MIXED' +SHOW WARNINGS; +Level Code Message +Warning 1105 MariaDB Galera does not support binlog format: MIXED +Error 1231 Variable 'binlog_format' can't be set to the value of 'MIXED' +SHOW VARIABLES LIKE 'binlog_format'; +Variable_name Value +binlog_format ROW +CREATE TABLE IF NOT EXISTS test.t2 AS SELECT * FROM information_schema.routines WHERE 1 = 0; +SET binlog_format=ROW; +SHOW WARNINGS; +Level Code Message +SHOW VARIABLES LIKE 'binlog_format'; +Variable_name Value +binlog_format ROW +CREATE TABLE IF NOT EXISTS test.t3 AS SELECT * FROM information_schema.routines WHERE 1 = 0; +DROP TABLE IF EXISTS test.t1; +DROP TABLE IF EXISTS test.t2; +DROP TABLE IF EXISTS test.t3; diff --git a/mysql-test/suite/wsrep/t/binlog_format.opt b/mysql-test/suite/wsrep/t/binlog_format.opt new file mode 100644 index 00000000000..901ead9a41d --- /dev/null +++ b/mysql-test/suite/wsrep/t/binlog_format.opt @@ -0,0 +1 @@ +--binlog-format=row --innodb_autoinc_lock_mode=2 --innodb_locks_unsafe_for_binlog=1 --wsrep-provider=/usr/lib/libgalera_smm.so --wsrep-cluster-address=gcomm:// --wsrep-on=1 --log-bin \ No newline at end of file diff --git a/mysql-test/suite/wsrep/t/binlog_format.test b/mysql-test/suite/wsrep/t/binlog_format.test new file mode 100644 index 00000000000..907fae5f4fb --- /dev/null +++ b/mysql-test/suite/wsrep/t/binlog_format.test @@ -0,0 +1,24 @@ +--source include/have_wsrep.inc +--source include/have_binlog_format_row.inc +# +# MDEV-4227: Galera server should stop crashing on setting binlog_format STATEMENT +# +SHOW VARIABLES LIKE 'binlog_format'; +-- error ER_WRONG_VALUE_FOR_VAR +SET binlog_format=STATEMENT; +SHOW WARNINGS; +SHOW VARIABLES LIKE 'binlog_format'; +CREATE TABLE IF NOT EXISTS test.t1 AS SELECT * FROM information_schema.routines WHERE 1 = 0; +-- error ER_WRONG_VALUE_FOR_VAR +SET binlog_format=MIXED; +SHOW WARNINGS; +SHOW VARIABLES LIKE 'binlog_format'; +CREATE TABLE IF NOT EXISTS test.t2 AS SELECT * FROM information_schema.routines WHERE 1 = 0; +SET binlog_format=ROW; +SHOW WARNINGS; +SHOW VARIABLES LIKE 'binlog_format'; +CREATE TABLE IF NOT EXISTS test.t3 AS SELECT * FROM information_schema.routines WHERE 1 = 0; +DROP TABLE IF EXISTS test.t1; +DROP TABLE IF EXISTS test.t2; +DROP TABLE IF EXISTS test.t3; + diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 98f4e644171..ef70b1e77d0 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -308,6 +308,26 @@ static bool binlog_format_check(sys_var *self, THD *thd, set_var *var) 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, MYSQL_ERROR::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; }