Debian Codegraph @

mysql-test/suite/rpl/include/rpl_start_stop_slave.test

raw
1 # Slow test, don't run during staging part
2 source include/not_staging.inc;
3
4 #
5 # Bug#6148 ()
6 #
7 # Let the master do lots of insertions
8
9 connection master;
10 call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
11
12 connection slave;
13 call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
14
15 connection master;
16 create table t1(n int);
17 sync_slave_with_master;
18 stop slave;
19 --source include/wait_for_slave_to_stop.inc
20 connection master;
21 let $1=2500;
22 disable_query_log;
23 while ($1)
24 {
25 eval insert into t1 values($1);
26 dec $1;
27 }
28 enable_query_log;
29 save_master_pos;
30
31 connection slave;
32 start slave;
33 let $wait_condition= SELECT COUNT(*) > 0 FROM t1;
34 source include/wait_condition.inc;
35 stop slave io_thread;
36 start slave io_thread;
37 source include/wait_for_slave_to_start.inc;
38 sync_with_master;
39
40 connection master;
41 drop table t1;
42 sync_slave_with_master;
43
44
45 #
46 # Bug#38205 Row-based Replication (RBR) causes inconsistencies...
47 # Bug#319 if while a non-transactional slave is replicating a transaction...
48 #
49 # Verifying that STOP SLAVE does not interrupt excution of a group
50 # execution of events if the group can not roll back.
51 # Killing the sql thread continues to provide a "hard" stop (the
52 # part II, moved to the bugs suite as it's hard to make it
53 # deterministic with KILL).
54 #
55
56 #
57 # Part I. The being stopped sql thread finishes first the current group of
58 # events if the group contains an event on a non-transaction table.
59
60 connection master;
61 create table t1i(n int primary key) engine=innodb;
62 create table t2m(n int primary key) engine=myisam;
63 begin;
64 insert into t1i values (1);
65 insert into t1i values (2);
66 insert into t1i values (3);
67 commit;
68
69 sync_slave_with_master;
70 connection slave;
71 begin;
72 insert into t1i values (5);
73
74 connection master;
75 let $pos0_master= query_get_value(SHOW MASTER STATUS, Position, 1);
76 begin;
77 insert into t1i values (4);
78 insert into t2m values (1); # non-ta update to process
79 insert into t1i values (5); # to block at. to be played with stopped
80 commit;
81
82 connection slave;
83 # slave sql thread must be locked out by the conn `slave' explicit lock
84 let $pos0_slave= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1);
85 --disable_query_log
86 eval select $pos0_master - $pos0_slave as zero;
87 --enable_query_log
88
89 connection slave1;
90 let $count= 1;
91 let $table= t2m;
92 source include/wait_until_rows_count.inc;
93 send stop slave;
94
95 connection slave;
96 rollback; # release the sql thread
97
98 connection slave1;
99 reap;
100 source include/wait_for_slave_to_stop.inc;
101 let $sql_status= query_get_value(SHOW SLAVE STATUS, Slave_SQL_Running, 1);
102 --echo *** sql thread is *not* running: $sql_status ***
103
104
105 connection master;
106 let $pos1_master= query_get_value(SHOW MASTER STATUS, Position, 1);
107
108 connection slave;
109
110 let $pos1_slave= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1);
111
112 --echo *** the prove: the stopped slave has finished the current transaction ***
113
114 --disable_query_log
115 select count(*) as five from t1i;
116 eval select $pos1_master - $pos1_slave as zero;
117 eval select $pos1_slave > $pos0_slave as one;
118 --enable_query_log
119
120 source include/start_slave.inc;
121
122 # clean-up
123 connection master;
124 drop table t1i, t2m;
125
126 sync_slave_with_master;
127
128 --echo #
129 --echo # Bug#56096 STOP SLAVE hangs if executed in parallel with user sleep
130 --echo #
131
132 --connection master
133
134 --disable_warnings
135 DROP TABLE IF EXISTS t1;
136 --enable_warnings
137
138 CREATE TABLE t1 (a INT );
139
140 sync_slave_with_master;
141
142 --connection slave1
143 --echo # lock table for synchronization
144 LOCK TABLES t1 WRITE;
145
146 --connection master
147 --echo # insert into the table
148 INSERT INTO t1 SELECT SLEEP(4);
149
150 --connection slave
151 --echo # Slave: wait for the insert
152 let $wait_condition=
153 SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST
154 WHERE STATE = "Waiting for table metadata lock"
155 AND INFO = "INSERT INTO t1 SELECT SLEEP(4)";
156 --source include/wait_condition.inc
157
158 --echo # send slave stop
159 --send STOP SLAVE
160
161 --connection slave1
162 --echo # wait for stop slave
163 let $wait_condition=
164 SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST
165 WHERE INFO = "STOP SLAVE";
166 --source include/wait_condition.inc
167
168 --echo # Slave1: unlock the table
169 UNLOCK TABLES;
170
171 --connection slave
172 --echo # wait for the slave to stop
173 --reap
174 --source include/wait_for_slave_to_stop.inc
175
176 --echo # Start slave again
177 --source include/start_slave.inc
178
179 --echo # Clean up
180 --connection master
181 DROP TABLE t1;
182 sync_slave_with_master;
183
184 #
185 # bug#3593869-64035 attempt to read a member of event_coordinates
186 # referenced by NULL pointer crashes server.
187 # Testing how out of valid range position value is handled with an error.
188 #
189
190 --connection master
191 RESET MASTER;
192 let $master_pos= query_get_value(SHOW MASTER STATUS, Position, 1);
193 let $master_pos= `SELECT $master_pos + 1`;
194
195 --connection slave
196 --source include/stop_slave.inc
197 --replace_regex /[0-9]+/MASTER_POS/
198 eval CHANGE MASTER TO master_log_pos=$master_pos, master_use_gtid=no;
199
200 START SLAVE;
201 # ER_MASTER_FATAL_ERROR_READING_BINLOG 1236
202 --let $slave_param=Last_IO_Errno
203 --let $slave_param_value=1236
204 --source include/wait_for_slave_param.inc
205
206 --let $slave_field_result_replace= / at [0-9]*/ at XXX/
207 --let $status_items= Last_IO_Errno, Last_IO_Error
208 --source include/show_slave_status.inc
209
210 --source include/stop_slave_sql.inc
211 RESET SLAVE;
212
213 --connection master
214 RESET MASTER;
215
216 # Slave is stopped by bug#3593869-64035 tests.