summaryrefslogtreecommitdiff
path: root/mysql-test/suite/rpl
diff options
context:
space:
mode:
authorunknown <knielsen@knielsen-hq.org>2013-05-03 11:27:29 +0200
committerunknown <knielsen@knielsen-hq.org>2013-05-03 11:27:29 +0200
commit5aa0d185ca18cf538eea5c9c501e1e342b41b274 (patch)
tree8f872bb7fa531d916028321f164ee6d7c9bd42d3 /mysql-test/suite/rpl
parenteb75edfb2b3ac024f0d47860056b8d42f7dc3911 (diff)
downloadmariadb-git-5aa0d185ca18cf538eea5c9c501e1e342b41b274.tar.gz
MDEV-4473: mysql_binlog_send() starts sending events from wrong GTID position in some master failover scenarios
Suppose binlog file X has in its Gtid_list_event: 0-1-3,0-2-5, and suppose the slave requests to start replicating after 0-1-3. In this case the bug was that master would start sending events from the start of X. This is wrong, because 0-2-4 and 0-2-5 are contained in X-1, and are needed by the slave. So these events were lost. On the other hand, if the slave requested 0-2-5, then it _is_ correct to start sending from the beginning of binlog file X, because 0-2-5 is the last GTID logged in earlier binlogs. The difference is that 0-2-5 is the last of the GTIDs in the Gtid_list_event. The problem was that the code did not check that the matched GTID was the last one in the list. Fixed by checking if the gtid requested by slave that matches a gtid in the Gtid_list_event is the last event for that domain in the list. If not, go back to a prior binlog to ensure all needed events are sent to slave. mysql-test/include/show_events.inc: Backport --let $binlog_file=LAST, used by MDEV-4473 test case.
Diffstat (limited to 'mysql-test/suite/rpl')
-rw-r--r--mysql-test/suite/rpl/r/rpl_gtid_mdev4473.result57
-rw-r--r--mysql-test/suite/rpl/t/rpl_gtid_mdev4473.cnf18
-rw-r--r--mysql-test/suite/rpl/t/rpl_gtid_mdev4473.test71
3 files changed, 146 insertions, 0 deletions
diff --git a/mysql-test/suite/rpl/r/rpl_gtid_mdev4473.result b/mysql-test/suite/rpl/r/rpl_gtid_mdev4473.result
new file mode 100644
index 00000000000..1289bbb7e20
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_gtid_mdev4473.result
@@ -0,0 +1,57 @@
+include/rpl_init.inc [topology=1->2,1->3]
+create table t1 (n int);
+insert into t1 values (1);
+insert into t1 values (2);
+include/stop_slave.inc
+include/wait_for_slave_to_stop.inc
+include/stop_slave.inc
+include/wait_for_slave_to_stop.inc
+reset slave all;
+CHANGE MASTER TO master_host = '127.0.0.1', master_port = SERVER_MYPORT_2,
+master_user='root', MASTER_USE_GTID=1;
+include/start_slave.inc
+include/wait_for_slave_to_start.inc
+flush logs;
+insert into t1 values (3);
+insert into t1 values (4);
+flush logs;
+CHANGE MASTER TO master_host = '127.0.0.1', master_port = SERVER_MYPORT_2,
+MASTER_USE_GTID=1;
+include/start_slave.inc
+select * from t1 order by n;
+n
+1
+2
+3
+4
+show binary logs;
+Log_name File_size
+master-bin.000001 #
+show binlog events in 'master-bin.000001' from <binlog_start>;
+Log_name Pos Event_type Server_id End_log_pos Info
+master-bin.000001 # Gtid # # GTID #-#-#
+master-bin.000001 # Query # # use `test`; create table t1 (n int)
+master-bin.000001 # Gtid # # BEGIN GTID #-#-#
+master-bin.000001 # Query # # use `test`; insert into t1 values (1)
+master-bin.000001 # Query # # COMMIT
+master-bin.000001 # Gtid # # BEGIN GTID #-#-#
+master-bin.000001 # Query # # use `test`; insert into t1 values (2)
+master-bin.000001 # Query # # COMMIT
+master-bin.000001 # Gtid # # BEGIN GTID #-#-#
+master-bin.000001 # Query # # use `test`; insert into t1 values (3)
+master-bin.000001 # Query # # COMMIT
+master-bin.000001 # Gtid # # BEGIN GTID #-#-#
+master-bin.000001 # Query # # use `test`; insert into t1 values (4)
+master-bin.000001 # Query # # COMMIT
+include/stop_slave.inc
+include/wait_for_slave_to_stop.inc
+reset slave all;
+CHANGE MASTER TO master_host = '127.0.0.1', master_port = SERVER_MYPORT_1,
+master_user = 'root', MASTER_USE_GTID=1;
+include/start_slave.inc
+include/stop_slave.inc
+CHANGE MASTER TO master_host = '127.0.0.1', master_port = SERVER_MYPORT_1,
+MASTER_USE_GTID=1;
+include/start_slave.inc
+drop table t1;
+include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/t/rpl_gtid_mdev4473.cnf b/mysql-test/suite/rpl/t/rpl_gtid_mdev4473.cnf
new file mode 100644
index 00000000000..4fe90e6a281
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_gtid_mdev4473.cnf
@@ -0,0 +1,18 @@
+!include ../my.cnf
+
+[mysqld.1]
+log-slave-updates
+loose-innodb
+
+[mysqld.2]
+log-slave-updates
+loose-innodb
+
+[mysqld.3]
+log-slave-updates
+loose-innodb
+
+[ENV]
+SERVER_MYPORT_3= @mysqld.3.port
+SERVER_MYSOCK_3= @mysqld.3.socket
+
diff --git a/mysql-test/suite/rpl/t/rpl_gtid_mdev4473.test b/mysql-test/suite/rpl/t/rpl_gtid_mdev4473.test
new file mode 100644
index 00000000000..549d11e9d1c
--- /dev/null
+++ b/mysql-test/suite/rpl/t/rpl_gtid_mdev4473.test
@@ -0,0 +1,71 @@
+--source include/have_innodb.inc
+--source include/have_binlog_format_mixed.inc
+
+--let $rpl_topology=1->2,1->3
+--source include/rpl_init.inc
+
+connection server_1;
+create table t1 (n int);
+insert into t1 values (1);
+insert into t1 values (2);
+save_master_pos;
+
+connection server_3;
+sync_with_master;
+source include/stop_slave.inc;
+source include/wait_for_slave_to_stop.inc;
+
+connection server_2;
+sync_with_master;
+source include/stop_slave.inc;
+source include/wait_for_slave_to_stop.inc;
+reset slave all;
+
+connection server_1;
+--replace_result $SERVER_MYPORT_2 SERVER_MYPORT_2
+eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $SERVER_MYPORT_2,
+ master_user='root', MASTER_USE_GTID=1;
+source include/start_slave.inc;
+source include/wait_for_slave_to_start.inc;
+
+connection server_2;
+flush logs;
+insert into t1 values (3);
+insert into t1 values (4);
+flush logs;
+save_master_pos;
+
+connection server_3;
+--replace_result $SERVER_MYPORT_2 SERVER_MYPORT_2
+eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $SERVER_MYPORT_2,
+ MASTER_USE_GTID=1;
+source include/start_slave.inc;
+sync_with_master;
+
+select * from t1 order by n;
+source include/show_binary_logs.inc;
+let $binlog_file=LAST;
+source include/show_binlog_events.inc;
+
+connection server_1;
+source include/stop_slave.inc;
+source include/wait_for_slave_to_stop.inc;
+reset slave all;
+
+connection server_2;
+--replace_result $SERVER_MYPORT_1 SERVER_MYPORT_1
+eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $SERVER_MYPORT_1,
+ master_user = 'root', MASTER_USE_GTID=1;
+source include/start_slave.inc;
+
+connection server_3;
+source include/stop_slave.inc;
+--replace_result $SERVER_MYPORT_1 SERVER_MYPORT_1
+eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $SERVER_MYPORT_1,
+ MASTER_USE_GTID=1;
+source include/start_slave.inc;
+
+connection server_1;
+drop table t1;
+
+--source include/rpl_end.inc