Debian Codegraph @

mysql-test/suite/rpl/t/rpl_start_alter_restart_slave.test

raw
1 # This test will restart the slave in middle of start alter commit alter processing
2 # slave will be restarted after start alter and before binlogging of commit alter,
3 # Then we will recieved commit alter from the master.
4 # Commit alter will act like standalone alter
5 # =====> SA SA CA(Stop Slave before binlogging) CA
6 #
7 --source include/have_log_bin.inc
8 --source include/have_innodb.inc
9 --source include/have_debug.inc
10 --source include/master-slave.inc
11
12 --connection slave
13 SET @old_debug_slave= @@global.debug_dbug;
14 --source include/stop_slave.inc
15 --let $gtid_strict_mode= `select @@gtid_strict_mode`
16 --let $slave_parallel_threads= `select @@slave_parallel_threads`
17 --let $slave_parallel_mode= `select @@slave_parallel_mode`
18 SET GLOBAL slave_parallel_threads=4;
19 set global slave_parallel_mode=optimistic;
20 set global gtid_strict_mode=1;
21
22 set global debug_dbug="+d,rpl_slave_stop_CA_before_binlog";
23
24 --source include/start_slave.inc
25 #
26 # SLAVE Shutdown
27 --connection master
28 SET @old_debug_master= @@global.debug_dbug;
29 set global debug_dbug="+d,start_alter_delay_master";
30 --let $binlog_alter_two_phase= `select @@binlog_alter_two_phase`
31 set global binlog_alter_two_phase=true;
32 create table t1( a int primary key, b int) engine=myisam;
33 create table t2( a int primary key, b int) engine=myisam;
34
35 --connect (con1,localhost,root,,)
36 --send alter table t1 add column c int;
37
38 --connection master
39 --echo # Get into binlog first and wait
40 --let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'debug sync point: now';
41 --source include/wait_condition.inc
42 --let $master_gtid_state = `select @@gtid_binlog_state`
43 --echo # master gtid state is $master_gtid_state
44
45 --connect (con2,localhost,root,,)
46 --send alter table t2 add column c int;
47
48 --connection master
49 --echo # Get into binlog next and wait as well
50 --let $wait_condition = SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'debug sync point: now';
51 --source include/wait_condition.inc
52 --let $master_gtid_state = `select @@gtid_binlog_state`
53 --echo # master gtid state is $master_gtid_state
54
55 # Memorize for slave's next sync with master
56 --let $master_pos=$master_gtid_state
57
58 set DEBUG_SYNC= "now signal alter_cont";
59
60 --connection con1
61 --reap
62 --connection con2
63 --reap
64 create table t3( a int primary key, b int) engine=innodb;
65 --let $master_gtid_state = `select @@gtid_binlog_state`
66 --echo # master gtid state is $master_gtid_state
67 --let $replace_regexp=/alter table t[12]/alter table <t>/ /id=[0-9]+/id=<seq_no>/
68 --source include/show_binlog_events2.inc
69
70 --echo # Stop Slave
71 --echo # As master binlog is SA SA CA CA
72 --echo # let's stop at first CA processing (in process_commit_alter)
73
74 --connection slave
75 --source include/sync_with_master_gtid.inc
76 --echo # wait for CA_1 waiting itself
77 --let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'debug sync point: now';
78 --source include/wait_condition.inc
79
80 # set debug_sync="now wait_for CA_1_processing";
81 connect(extra_slave,127.0.0.1,root,,test,$SLAVE_MYPORT);
82 --send stop slave;
83 --connection slave
84 # set debug_sync="now signal proceed_CA_1";
85 --connection extra_slave
86 --reap
87 SET GLOBAL debug_dbug= @old_debug_slave;
88
89 --connection slave
90 --source include/wait_for_slave_sql_to_stop.inc
91 --echo # The list of events after the slave has stopped must have just one CA:
92 --let $replace_regexp=/alter table t[12]/alter table <t>/ /id=[0-9]+/id=<seq_no>/
93 --source include/show_binlog_events2.inc
94
95 select domain_id, seq_no from mysql.gtid_slave_pos order by seq_no desc limit 1;
96 --source include/start_slave.inc
97
98 --connection master
99 --source include/save_master_gtid.inc
100
101 --connection slave
102 --source include/sync_with_master_gtid.inc
103 --echo # Everything from the master binlog must have been applied now:
104 select domain_id, seq_no from mysql.gtid_slave_pos order by seq_no desc limit 1;
105 --let $slave_gtid_state = `select @@gtid_binlog_state`
106 --echo # slave gtid state is $slave_gtid_state
107 if (`select $master_gtid_state <> $slave_gtid_state`)
108 {
109 --echo Gtid state mismatch: $master_gtid_state <> $slave_gtid_state
110 --die
111 }
112 --echo # The list of events after the slave has synchronized must have both CA:
113 --let $replace_regexp=/alter table t[12]/alter table <t>/ /id=[0-9]+/id=<seq_no>/
114 --source include/show_binlog_events2.inc
115
116 --connection master
117 drop table t1,t2,t3;
118 --eval set global binlog_alter_two_phase = $binlog_alter_two_phase
119 SET GLOBAL debug_dbug= @old_debug_master;
120 set DEBUG_SYNC= 'RESET';
121
122 --sync_slave_with_master
123 --source include/stop_slave.inc
124 --eval set global slave_parallel_threads = $slave_parallel_threads;
125 --eval set global slave_parallel_mode = $slave_parallel_mode;
126 --eval set global gtid_strict_mode = $gtid_strict_mode;
127 set DEBUG_SYNC= 'RESET';
128 --source include/start_slave.inc
129 --source include/rpl_end.inc