Commit 581b49dd authored by Nirbhay Choubey's avatar Nirbhay Choubey

MDEV-7995 : DMLs not getting replicated with log-bin=OFF & binlog-format != ROW

This bug is a side-effect of fix for MDEV-6924, where we completely
stopped a statement-based event from getting into the binlog cache when
binary logging is not enabled (and thus, wsrep_emulate_binlog mode = 1).
As a result, the SBR events were not replicated.

Fixed by allowing the SBR events to be written into the binlog cache.

Note: Only DMLs were affected as DDLs are replicated via TOI.

Merged galera_create_trigger.test from github.com/codership/mysql-wsrep.
parent d7445ea6
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';
#
# 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';
......@@ -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;
......
......@@ -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);
......
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