Skip to content

Commit

Permalink
MDEV-11149: wsrep_replicate_mysaim: DML fails when binlog checksum en…
Browse files Browse the repository at this point in the history
…abled

During total-order replication, Query_log_event's checksum_alg
should be explicitly set to the current binlog_checksum as it
is not set for DML queries.
Note: wsrep_replicate_myisam enables replication of DMLs on
MyISAM tables using TOI.
  • Loading branch information
Nirbhay Choubey committed Nov 7, 2016
1 parent db95beb commit 9b6bd3f
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
16 changes: 16 additions & 0 deletions mysql-test/suite/galera/r/galera_binlog_checksum.result
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,19 @@ SELECT COUNT(*) = 1 FROM t1 WHERE f1 = 2;
COUNT(*) = 1
1
DROP TABLE t1;
#
# MDEV-11149: wsrep_replicate_mysaim: DML fails when binlog checksum
# enabled
#
connection node_1;
SET @@global.wsrep_replicate_myisam=1;
CREATE TABLE t1 (i INT) ENGINE=MYISAM;
INSERT INTO t1 VALUES(1);
connection node_2;
SELECT * FROM t1;
i
1
connection node_1;
DROP TABLE t1;
SET @@global.wsrep_replicate_myisam=0;
# End of tests.
21 changes: 21 additions & 0 deletions mysql-test/suite/galera/t/galera_binlog_checksum.test
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,24 @@ UPDATE t1 SET f1 = 2 WHERE f1 = 1;
SELECT COUNT(*) = 1 FROM t1 WHERE f1 = 2;

DROP TABLE t1;

--echo #
--echo # MDEV-11149: wsrep_replicate_mysaim: DML fails when binlog checksum
--echo # enabled
--echo #

--connection node_1
let $wsrep_replicate_myisam_saved= `SELECT @@wsrep_replicate_myisam`;
SET @@global.wsrep_replicate_myisam=1;

CREATE TABLE t1 (i INT) ENGINE=MYISAM;
INSERT INTO t1 VALUES(1);

--connection node_2
SELECT * FROM t1;

--connection node_1
DROP TABLE t1;
eval SET @@global.wsrep_replicate_myisam=$wsrep_replicate_myisam_saved;

--echo # End of tests.
6 changes: 5 additions & 1 deletion sql/wsrep_mysqld.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1248,9 +1248,11 @@ int wsrep_to_buf_helper(
65536, MYF(MY_WME)))
return 1;
int ret(0);
enum enum_binlog_checksum_alg current_binlog_check_alg=
(enum_binlog_checksum_alg) binlog_checksum_options;

Format_description_log_event *tmp_fd= new Format_description_log_event(4);
tmp_fd->checksum_alg= (enum_binlog_checksum_alg)binlog_checksum_options;
tmp_fd->checksum_alg= current_binlog_check_alg;
writer.write(tmp_fd);
delete tmp_fd;

Expand All @@ -1269,11 +1271,13 @@ int wsrep_to_buf_helper(
Query_log_event ev(thd, thd->wsrep_TOI_pre_query,
thd->wsrep_TOI_pre_query_len,
FALSE, FALSE, FALSE, 0);
ev.checksum_alg= current_binlog_check_alg;
if (writer.write(&ev)) ret= 1;
}

/* continue to append the actual query */
Query_log_event ev(thd, query, query_len, FALSE, FALSE, FALSE, 0);
ev.checksum_alg= current_binlog_check_alg;
if (!ret && writer.write(&ev)) ret= 1;
if (!ret && wsrep_write_cache_buf(&tmp_io_cache, buf, buf_len)) ret= 1;
close_cached_file(&tmp_io_cache);
Expand Down

0 comments on commit 9b6bd3f

Please sign in to comment.