Debian Codegraph @

mysql-test/suite/rpl_nogtid/t/rpl_slave_skip.test

raw
1 # Every statement in this test is either executing under ROW or
2 # STATEMENT format, which requires the slave thread to be able to apply
3 # both statement and row events. Hence, we only need to execute this
4 # test for MIXED mode.
5 # Skip in valgrind because of bug#20952953
6 --source include/not_valgrind.inc
7 source include/have_binlog_format_mixed.inc;
8
9 source include/master-slave.inc;
10 source include/have_myisam.inc;
11
12 --echo **** On Slave ****
13 connection slave;
14
15 STOP SLAVE;
16 --source include/wait_for_slave_to_stop.inc
17
18 --echo **** On Master ****
19 connection master;
20 SET SESSION BINLOG_FORMAT='ROW';
21
22 CREATE TABLE t1 (a INT, b INT) ENGINE=MyISAM;
23 CREATE TABLE t2 (c INT, d INT) ENGINE=MyISAM;
24 INSERT INTO t1 VALUES (1,1),(2,4),(3,9);
25 INSERT INTO t2 VALUES (1,1),(2,8),(3,27);
26 let $master_log_pos= query_get_value(SHOW MASTER STATUS, Position, 1);
27 UPDATE t1,t2 SET b = d, d = b * 2 WHERE a = c;
28 source include/show_binlog_events.inc;
29
30 # These tables should be changed
31 SELECT * FROM t1;
32 SELECT * FROM t2;
33 save_master_pos;
34 --echo **** On Slave ****
35 connection slave;
36
37 # Stop when reaching the the first table map event.
38 --replace_result $master_log_pos MASTER_LOG_POS
39 eval START SLAVE UNTIL SOURCE_LOG_FILE='master-bin.000001', SOURCE_LOG_POS=$master_log_pos;
40 source include/wait_for_slave_sql_to_stop.inc;
41 let $slave_param= Exec_Master_Log_Pos;
42 let $slave_param_value= $master_log_pos;
43 source include/check_slave_param.inc;
44 source include/check_slave_no_error.inc;
45
46 # Now we skip *one* table map event. If the execution starts right
47 # after that table map event, *one* of the involved tables will be
48 # changed.
49 SET GLOBAL SQL_REPLICA_SKIP_COUNTER=2;
50 START SLAVE;
51 --source include/wait_for_slave_to_start.inc
52 sync_with_master;
53
54 # These values should be what was inserted, not what was
55 # updated. Since we are skipping the first table map of the group
56 # representing the UPDATE statement above, we should skip the entire
57 # group and not start executing at the first table map.
58 SELECT * FROM t1;
59 SELECT * FROM t2;
60
61 STOP SLAVE;
62 --source include/wait_for_slave_to_stop.inc
63 RESET SLAVE;
64 connection master;
65 RESET MASTER;
66
67 SET SESSION BINLOG_FORMAT=STATEMENT;
68 SET @foo = 12;
69 let $master_log_pos= query_get_value(SHOW MASTER STATUS, Position, 1);
70 INSERT INTO t1 VALUES(@foo, 2*@foo);
71 save_master_pos;
72 source include/show_binlog_events.inc;
73
74 connection slave;
75 --replace_result $master_log_pos MASTER_LOG_POS
76 eval START SLAVE UNTIL SOURCE_LOG_FILE='master-bin.000001', SOURCE_LOG_POS=$master_log_pos;
77 source include/wait_for_slave_sql_to_stop.inc;
78 SET GLOBAL SQL_REPLICA_SKIP_COUNTER=2;
79 START SLAVE;
80 --source include/wait_for_slave_to_start.inc
81 sync_with_master;
82
83 --echo **** On Master ****
84 connection master;
85 DROP TABLE t1, t2;
86 --source include/sync_slave_sql_with_master.inc
87
88 #
89 # More tests for BUG#28618
90 #
91 --echo **** Case 2: Row binlog format and transactional tables ****
92
93 # Create the transaction and try to skip some
94 # queries from one.
95
96 --echo *** On Master ***
97 connection master;
98 CREATE TABLE t4 (a INT, b VARCHAR(20)) ENGINE=innodb;
99 CREATE TABLE t5 (a INT, b VARCHAR(20)) ENGINE=innodb;
100 CREATE TABLE t6 (a INT, b VARCHAR(20)) ENGINE=innodb;
101
102 --echo **** On Slave ****
103 --source include/sync_slave_sql_with_master.inc
104 source include/stop_slave.inc;
105
106 --echo *** On Master ***
107 connection master;
108 BEGIN;
109 INSERT INTO t4 VALUES (2, 'master only');
110 INSERT INTO t5 VALUES (2, 'master only');
111 INSERT INTO t6 VALUES (2, 'master only');
112 COMMIT;
113
114 BEGIN;
115 INSERT INTO t4 VALUES (3, 'master/slave');
116 INSERT INTO t5 VALUES (3, 'master/slave');
117 INSERT INTO t6 VALUES (3, 'master/slave');
118 COMMIT;
119
120 SELECT * FROM t4 ORDER BY a;
121 SELECT * FROM t5 ORDER BY a;
122 SELECT * FROM t6 ORDER BY a;
123
124 save_master_pos;
125
126 --echo *** On Slave ***
127 connection slave;
128 SET GLOBAL SQL_REPLICA_SKIP_COUNTER=2;
129 source include/start_slave.inc;
130 sync_with_master;
131
132 SELECT * FROM t4 ORDER BY a;
133 SELECT * FROM t5 ORDER BY a;
134 SELECT * FROM t6 ORDER BY a;
135
136 # Test skipping two groups
137
138 --echo **** On Slave ****
139 connection slave;
140 source include/stop_slave.inc;
141
142 --echo *** On Master ***
143 connection master;
144 BEGIN;
145 INSERT INTO t4 VALUES (6, 'master only');
146 INSERT INTO t5 VALUES (6, 'master only');
147 INSERT INTO t6 VALUES (6, 'master only');
148 COMMIT;
149
150 BEGIN;
151 INSERT INTO t4 VALUES (7, 'master only');
152 INSERT INTO t5 VALUES (7, 'master only');
153 INSERT INTO t6 VALUES (7, 'master only');
154 COMMIT;
155
156 SELECT * FROM t4 ORDER BY a;
157 SELECT * FROM t5 ORDER BY a;
158 SELECT * FROM t6 ORDER BY a;
159
160 save_master_pos;
161
162 --echo *** On Slave ***
163 connection slave;
164 SET GLOBAL SQL_REPLICA_SKIP_COUNTER=11;
165 source include/start_slave.inc;
166 sync_with_master;
167
168 SELECT * FROM t4 ORDER BY a;
169 SELECT * FROM t5 ORDER BY a;
170 SELECT * FROM t6 ORDER BY a;
171
172 #
173 # And the same, but with autocommit = 0
174 #
175 connection slave;
176 source include/stop_slave.inc;
177
178 connection master;
179 SET AUTOCOMMIT=0;
180
181 INSERT INTO t4 VALUES (4, 'master only');
182 INSERT INTO t5 VALUES (4, 'master only');
183 INSERT INTO t6 VALUES (4, 'master only');
184 COMMIT;
185
186 INSERT INTO t4 VALUES (5, 'master/slave');
187 INSERT INTO t5 VALUES (5, 'master/slave');
188 INSERT INTO t6 VALUES (5, 'master/slave');
189 COMMIT;
190
191 SELECT * FROM t4 ORDER BY a;
192 SELECT * FROM t5 ORDER BY a;
193 SELECT * FROM t6 ORDER BY a;
194
195 save_master_pos;
196
197 --echo *** On Slave ***
198 connection slave;
199 SET GLOBAL SQL_REPLICA_SKIP_COUNTER=2;
200 source include/start_slave.inc;
201 sync_with_master;
202
203 SELECT * FROM t4 ORDER BY a;
204 SELECT * FROM t5 ORDER BY a;
205 SELECT * FROM t6 ORDER BY a;
206
207 connection master;
208 DROP TABLE t4, t5, t6;
209 --source include/sync_slave_sql_with_master.inc
210
211 --source include/rpl_end.inc