mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
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.
This commit is contained in:
14
mysql-test/suite/galera/r/galera_sbr.result
Normal file
14
mysql-test/suite/galera/r/galera_sbr.result
Normal file
@@ -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';
|
27
mysql-test/suite/galera/t/galera_sbr.test
Normal file
27
mysql-test/suite/galera/t/galera_sbr.test
Normal file
@@ -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';
|
18
sql/log.cc
18
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;
|
binlog_cache_data *cache_data= 0;
|
||||||
bool is_trans_cache= FALSE;
|
bool is_trans_cache= FALSE;
|
||||||
bool using_trans= event_info->use_trans_cache();
|
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)
|
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");
|
DBUG_ENTER("MYSQL_BIN_LOG::write_transaction_to_binlog");
|
||||||
|
|
||||||
#ifdef WITH_WSREP
|
#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);
|
if (wsrep_emulate_bin_log) DBUG_RETURN(0);
|
||||||
#endif /* WITH_WSREP */
|
#endif /* WITH_WSREP */
|
||||||
entry.thd= thd;
|
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
|
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);
|
||||||
|
Reference in New Issue
Block a user