diff --git a/mysql-test/suite/galera/r/galera_sbr.result b/mysql-test/suite/galera/r/galera_sbr.result new file mode 100644 index 00000000000..0bf6cc7c9d3 --- /dev/null +++ b/mysql-test/suite/galera/r/galera_sbr.result @@ -0,0 +1,14 @@ +SET SESSION binlog_format = 'STATEMENT'; +Warnings: +Warning 1105 MariaDB Galera does not support binlog format: STATEMENT +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +SET SESSION binlog_format = 'MIXED'; +Warnings: +Warning 1105 MariaDB Galera does not support binlog format: MIXED +INSERT INTO t1 VALUES (2); +SELECT COUNT(*) = 2 FROM t1; +COUNT(*) = 2 +1 +DROP TABLE t1; +SET GLOBAL binlog_format = 'ROW'; diff --git a/mysql-test/suite/galera/t/galera_sbr.test b/mysql-test/suite/galera/t/galera_sbr.test new file mode 100644 index 00000000000..33f45c6b532 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_sbr.test @@ -0,0 +1,27 @@ +# +# Test behavior if the user attempts to use statement-based replication +# +# SBR is not currently supported but we expect that no crashes or binlog-related assertions will be triggered. +# + +--source include/have_innodb.inc +--source include/galera_cluster.inc + +--connection node_1 +#SET GLOBAL binlog_format = 'STATEMENT'; +SET SESSION binlog_format = 'STATEMENT'; + +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); + +SET SESSION binlog_format = 'MIXED'; + +INSERT INTO t1 VALUES (2); + +--connection node_2 +SELECT COUNT(*) = 2 FROM t1; + +DROP TABLE t1; + +--connection node_1 +SET GLOBAL binlog_format = 'ROW'; diff --git a/sql/log.cc b/sql/log.cc index d4403f4dfa4..8b2eb98c2e2 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -5167,7 +5167,19 @@ bool MYSQL_BIN_LOG::write(Log_event *event_info, my_bool *with_annotate) binlog_cache_data *cache_data= 0; bool is_trans_cache= FALSE; bool using_trans= event_info->use_trans_cache(); - bool direct= event_info->use_direct_logging(); + bool direct; + +#ifdef WITH_WSREP + /* + When binary logging is not enabled (--log-bin=0), wsrep-patch partially + enables it without opening the binlog file (MSQL_BIN_LOG::open(). + So, avoid writing directly to binlog file. + */ + if (wsrep_emulate_bin_log) + direct= false; + else +#endif /* WITH_WSREP */ + direct= event_info->use_direct_logging(); if (thd->binlog_evt_union.do_union) { @@ -5948,6 +5960,10 @@ MYSQL_BIN_LOG::write_transaction_to_binlog(THD *thd, DBUG_ENTER("MYSQL_BIN_LOG::write_transaction_to_binlog"); #ifdef WITH_WSREP + /* + Control should not be allowed beyond this point in wsrep_emulate_bin_log + mode. + */ if (wsrep_emulate_bin_log) DBUG_RETURN(0); #endif /* WITH_WSREP */ entry.thd= thd; diff --git a/sql/sql_class.cc b/sql/sql_class.cc index d40ca89a5ab..a55992bd0cf 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -5885,16 +5885,6 @@ 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 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);