1#
2# Testing chain/circular replication scenario of MDEV-9670
3# The effect of the bug was that we got a commit with a GTID with server_id
4#
5
6--source include/have_binlog_format_row.inc
7--source include/have_innodb.inc
8--source include/have_debug.inc
9--source include/have_debug_sync.inc
10
11--let $rpl_topology= 1->2->1
12--source include/rpl_init.inc
13
14--let $rpl_connection_name= M4
15--let $rpl_server_number= 1
16--source include/rpl_connect.inc
17
18--let $rpl_connection_name= M2
19--let $rpl_server_number= 2
20--source include/rpl_connect.inc
21
22# The parameter reflects binlog-row-event-max-size @cnf.
23--let $row_size=1024
24
25--connection M2
26STOP SLAVE;
27SET @old_debug= @@global.debug_dbug;
28SET GLOBAL debug_dbug= "d,dbug.rows_events_to_delay_relay_logging";
29START SLAVE IO_THREAD;
30--source include/wait_for_slave_io_to_start.inc
31
32--connection M2
33# This query also creates a Gtid event group whose Gtid will remain in
34# ignored status for too long causing a following group split.
35
36CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY, b VARCHAR(30000)) ENGINE=innodb;
37--sync_slave_with_master M4
38
39# This INSERT will be logged as two Write_log events which the buggy
40# slave applier would split.
41
42--connection M4
43eval INSERT INTO `t1` VALUES (null, repeat('a', $row_size)), (null, repeat('b', $row_size));
44
45# START M2 IO thread and wait for its signal to follow with the SQL
46# thread start.  At this moment the SQL thread shall be having 2 and
47# "half" groups to execute.  The "hafl" one would be committed by the
48# buggy applier after which the IO is released to queue the rest of
49# the 3rd group which the SQL thread commits separately to complete
50# the split.
51
52--connection M2
53
54# wait for IO signal to start the SQL thread. IO will be hanging upon that.
55SET debug_sync='now WAIT_FOR start_sql_thread';
56
57# Now the slave server has relay log whose last group is incomplete.
58# An unfixed slave server would go to "insert" a "fake"
59# Gtid_list_log_event event which actually would commit the incomplete
60# group. However before to actual commit do_apply_event() hits some assert.
61# In the fixed server the fake Gtid_list_log_event is *not* inserted
62# in the middle of a group.
63START SLAVE SQL_THREAD;
64
65# Sleep for a little time to give SQL thread a chance to commit while
66# the IO thread is hanging (see
67# DBUG_EXECUTE_IF("dbug.rows_events_to_delay_relay_logging"...) in
68# queue_event).  Alternatively to reproduce the case when buggy slave
69# wait for the 1st group commit
70
71#--let $count= 1
72#--let $table= t1
73#--source include/wait_until_rows_count.inc
74
75--sleep 2
76
77# Demonstrate either no split group in the correct slave or the 1nd
78# group in the buggy one
79--source include/show_binlog_events.inc
80
81# Release the IO thread
82SET debug_sync='now SIGNAL go_on_relay_logging';
83
84# Sync servers
85--sync_slave_with_master M4
86--connection M4
87--sync_slave_with_master M2
88--connection M2
89
90# Demonstrate replication goes correctly not to create any split, or
91# the 2nd group in the buggy slave
92--source include/show_binlog_events.inc
93
94#
95# Cleanup
96#
97--connection M4
98drop table t1;
99
100--connection M2
101SET GLOBAL debug_dbug= @old_debug;
102SET debug_sync='RESET';
103--source include/rpl_end.inc
104