Skip to content

Commit 581b49d

Browse files
author
Nirbhay Choubey
committed
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.
1 parent d7445ea commit 581b49d

File tree

4 files changed

+58
-11
lines changed

4 files changed

+58
-11
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
SET SESSION binlog_format = 'STATEMENT';
2+
Warnings:
3+
Warning 1105 MariaDB Galera does not support binlog format: STATEMENT
4+
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
5+
INSERT INTO t1 VALUES (1);
6+
SET SESSION binlog_format = 'MIXED';
7+
Warnings:
8+
Warning 1105 MariaDB Galera does not support binlog format: MIXED
9+
INSERT INTO t1 VALUES (2);
10+
SELECT COUNT(*) = 2 FROM t1;
11+
COUNT(*) = 2
12+
1
13+
DROP TABLE t1;
14+
SET GLOBAL binlog_format = 'ROW';
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#
2+
# Test behavior if the user attempts to use statement-based replication
3+
#
4+
# SBR is not currently supported but we expect that no crashes or binlog-related assertions will be triggered.
5+
#
6+
7+
--source include/have_innodb.inc
8+
--source include/galera_cluster.inc
9+
10+
--connection node_1
11+
#SET GLOBAL binlog_format = 'STATEMENT';
12+
SET SESSION binlog_format = 'STATEMENT';
13+
14+
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
15+
INSERT INTO t1 VALUES (1);
16+
17+
SET SESSION binlog_format = 'MIXED';
18+
19+
INSERT INTO t1 VALUES (2);
20+
21+
--connection node_2
22+
SELECT COUNT(*) = 2 FROM t1;
23+
24+
DROP TABLE t1;
25+
26+
--connection node_1
27+
SET GLOBAL binlog_format = 'ROW';

sql/log.cc

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5167,7 +5167,19 @@ bool MYSQL_BIN_LOG::write(Log_event *event_info, my_bool *with_annotate)
51675167
binlog_cache_data *cache_data= 0;
51685168
bool is_trans_cache= FALSE;
51695169
bool using_trans= event_info->use_trans_cache();
5170-
bool direct= event_info->use_direct_logging();
5170+
bool direct;
5171+
5172+
#ifdef WITH_WSREP
5173+
/*
5174+
When binary logging is not enabled (--log-bin=0), wsrep-patch partially
5175+
enables it without opening the binlog file (MSQL_BIN_LOG::open().
5176+
So, avoid writing directly to binlog file.
5177+
*/
5178+
if (wsrep_emulate_bin_log)
5179+
direct= false;
5180+
else
5181+
#endif /* WITH_WSREP */
5182+
direct= event_info->use_direct_logging();
51715183

51725184
if (thd->binlog_evt_union.do_union)
51735185
{
@@ -5948,6 +5960,10 @@ MYSQL_BIN_LOG::write_transaction_to_binlog(THD *thd,
59485960
DBUG_ENTER("MYSQL_BIN_LOG::write_transaction_to_binlog");
59495961

59505962
#ifdef WITH_WSREP
5963+
/*
5964+
Control should not be allowed beyond this point in wsrep_emulate_bin_log
5965+
mode.
5966+
*/
59515967
if (wsrep_emulate_bin_log) DBUG_RETURN(0);
59525968
#endif /* WITH_WSREP */
59535969
entry.thd= thd;

sql/sql_class.cc

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5885,16 +5885,6 @@ int THD::binlog_query(THD::enum_binlog_query_type qtype, char const *query_arg,
58855885
The MYSQL_LOG::write() function will set the STMT_END_F flag and
58865886
flush the pending rows event if necessary.
58875887
*/
5888-
#ifdef WITH_WSREP
5889-
/*
5890-
Even though wsrep only supports ROW binary log format, a user can set
5891-
binlog format to STATEMENT (wsrep_forced_binlog_format). In which case
5892-
the control might reach here even when binary logging (--log-bin) is
5893-
not enabled. This is possible because wsrep patch partially enables
5894-
binary logging by setting wsrep_emulate_binlog.
5895-
*/
5896-
if (mysql_bin_log.is_open())
5897-
#endif /* WITH_WSREP */
58985888
{
58995889
Query_log_event qinfo(this, query_arg, query_len, is_trans, direct,
59005890
suppress_use, errcode);

0 commit comments

Comments
 (0)