Commit 6f65d2d1 authored by Nirbhay Choubey's avatar Nirbhay Choubey

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.
parent 7dd74fa3
#
# 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
--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
call mtr.add_suppression("WSREP: cannot get fake InnoDB transaction ID"); 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: 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'; SHOW VARIABLES LIKE 'binlog_format';
Variable_name Value Variable_name Value
binlog_format ROW binlog_format ROW
...@@ -33,3 +34,18 @@ CREATE TABLE IF NOT EXISTS test.t3 AS SELECT * FROM information_schema.routines ...@@ -33,3 +34,18 @@ CREATE TABLE IF NOT EXISTS test.t3 AS SELECT * FROM information_schema.routines
DROP TABLE IF EXISTS test.t1; DROP TABLE IF EXISTS test.t1;
DROP TABLE IF EXISTS test.t2; DROP TABLE IF EXISTS test.t2;
DROP TABLE IF EXISTS test.t3; 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.
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
# #
call mtr.add_suppression("WSREP: cannot get fake InnoDB transaction ID"); 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: 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'; SHOW VARIABLES LIKE 'binlog_format';
-- error ER_WRONG_VALUE_FOR_VAR -- error ER_WRONG_VALUE_FOR_VAR
...@@ -25,3 +26,15 @@ DROP TABLE IF EXISTS test.t1; ...@@ -25,3 +26,15 @@ DROP TABLE IF EXISTS test.t1;
DROP TABLE IF EXISTS test.t2; DROP TABLE IF EXISTS test.t2;
DROP TABLE IF EXISTS test.t3; 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.
--source include/have_wsrep.inc --source include/have_wsrep.inc
--source include/have_binlog_format_row.inc
--echo --echo
--echo # --echo #
......
...@@ -9631,6 +9631,15 @@ static int get_options(int *argc_ptr, char ***argv_ptr) ...@@ -9631,6 +9631,15 @@ static int get_options(int *argc_ptr, char ***argv_ptr)
global_system_variables.option_bits&= ~OPTION_BIG_SELECTS; global_system_variables.option_bits&= ~OPTION_BIG_SELECTS;
#ifdef WITH_WSREP #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) { if (global_system_variables.wsrep_causal_reads) {
WSREP_WARN("option --wsrep-casual-reads is deprecated"); WSREP_WARN("option --wsrep-casual-reads is deprecated");
if (!(global_system_variables.wsrep_sync_wait & if (!(global_system_variables.wsrep_sync_wait &
......
...@@ -6590,6 +6590,16 @@ int THD::binlog_query(THD::enum_binlog_query_type qtype, char const *query_arg, ...@@ -6590,6 +6590,16 @@ int THD::binlog_query(THD::enum_binlog_query_type qtype, char const *query_arg,
The MYSQL_LOG::write() function will set the STMT_END_F flag and The MYSQL_LOG::write() function will set the STMT_END_F flag and
flush the pending rows event if necessary. 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, Query_log_event qinfo(this, query_arg, query_len, is_trans, direct,
suppress_use, errcode); suppress_use, errcode);
......
...@@ -437,6 +437,24 @@ static bool binlog_format_check(sys_var *self, THD *thd, set_var *var) ...@@ -437,6 +437,24 @@ static bool binlog_format_check(sys_var *self, THD *thd, set_var *var)
if (check_has_super(self, thd, var)) if (check_has_super(self, thd, var))
return true; 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) if (var->type == OPT_GLOBAL)
return false; return false;
...@@ -465,26 +483,6 @@ static bool binlog_format_check(sys_var *self, THD *thd, set_var *var) ...@@ -465,26 +483,6 @@ static bool binlog_format_check(sys_var *self, THD *thd, set_var *var)
ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_BINLOG_FORMAT)) ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_BINLOG_FORMAT))
return true; 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; return false;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment