File: rpl_stop_middle_group.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (173 lines) | stat: -rw-r--r-- 5,609 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# Proving that stopping in the middle of applying a group of events
# does not have immediate effect if a non-transaction table has been changed.
# The slave sql thread has to try to finish applying first.
# The tests rely on simulation of the killed status.
# The matter of testing correlates to some of `rpl_start_stop_slave' that does
# not require `have_debug'.

# Test group sematics and thereby failing in such group is bound to
# the Single-Threaded Slave.
-- source include/have_myisam.inc

connection master;

call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");

create table tm (a int auto_increment primary key) engine=myisam;
create table ti (a int auto_increment primary key) engine=innodb;

sync_slave_with_master;
set @@global.debug="+d,stop_replica_middle_group";

connection master;

begin;
insert into ti set a=null;
insert into tm set a=null; # to simulate killed status on the slave
commit;

connection slave;
call mtr.add_suppression("Replica SQL.*Request to stop replica SQL Thread received while applying a group that has non-transactional changes; waiting for completion of the group");
call mtr.add_suppression("Replica SQL.*Replica SQL Thread stopped with incomplete event group having non-transactional changes");
call mtr.add_suppression("Replica SQL.*The replica coordinator and worker threads are stopped.*");

# slave will catch the killed status but won't shut down immediately
# only after the whole group has done (commit)

source include/wait_for_slave_sql_to_stop.inc;

# checking: no error and the group is finished

--source include/check_slave_no_error.inc

--let $assert_text= Everything that was read, was executed
--let $assert_cond= [SHOW SLAVE STATUS, Read_Master_Log_Pos, 1] = [SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1]
--source include/assert.inc

--let $assert_text= There is one row in table tm
--let $assert_cond= [SELECT COUNT(*) AS Val FROM tm, Val, 1] = 1
--source include/assert.inc

--let $assert_text= There is one row in table ti
--let $assert_cond= [SELECT COUNT(*) AS Val FROM ti, Val, 1] = 1
--source include/assert.inc

--source include/stop_slave.inc
set @@global.debug="-d,stop_replica_middle_group";

#
# bug#45940 issues around rli->last_event_start_time
# Testing of slave stopped after it had waited (in vain) for
# the group be finished.
# It could not be finished because of simulation of failure to
# receive the terminal part
# The test relay on simulation of the incomplete group in the relay log

# Two cases are verified: a mixed transacton and a mixed multi-table update.
#
# The mixed transacton.
#
source include/start_slave.inc;

connection master;

truncate table tm; # cleanup of former tests
truncate table ti;

#connection slave;
sync_slave_with_master;

set @@global.debug="+d,stop_replica_middle_group";
set @@global.debug="+d,incomplete_group_in_relay_log";

connection master;

begin;
insert into ti set a=null;
insert into tm set a=null;
commit;

connection slave;

# slave will catch the killed status, won't shut down immediately
# but does it eventually having the whole group unfinished (not committed)

let $slave_sql_errno= 13117,1756; # ER_REPLICA_FATAL_ERROR, ER_MTA_INCONSISTENT_DATA
--let $show_slave_sql_error= 0
--source include/wait_for_slave_sql_error.inc

# checking: the error and group unfinished

--let $assert_text= Not everything that was read, was executed
--let $assert_cond= [SHOW SLAVE STATUS, Read_Master_Log_Pos, 1] > [SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1]
--source include/assert.inc

--let $assert_text= There is one row in table tm
--let $assert_cond= [SELECT COUNT(*) AS Val FROM tm, Val, 1] = 1
--source include/assert.inc

--let $assert_text= There is no row in table ti
--let $assert_cond= [SELECT COUNT(*) AS Val FROM ti, Val, 1] = 0
--source include/assert.inc

--source include/stop_slave.inc
set @@global.debug="-d,stop_replica_middle_group";
set @@global.debug="-d,incomplete_group_in_relay_log";

#
# The mixed multi-table update
#

# above tests for Bug#11765758 - 58754 made sure slave is down

truncate table tm;
source include/start_slave.inc;

connection master;

#connection slave;
sync_slave_with_master;
set @@global.debug="+d,stop_replica_middle_group";
set @@global.debug="+d,incomplete_group_in_relay_log";

connection master;
update tm as t1, ti as t2 set t1.a=t1.a * 2, t2.a=t2.a * 2;

connection slave;

# slave will catch the killed status, won't shut down immediately
# but does it eventually having the whole group unfinished (not committed)
#

# checking: the error and group unfinished
let $slave_sql_errno= 13117,1756; # ER_REPLICA_FATAL_ERROR, ER_MTA_INCONSISTENT_DATA
--let $show_slave_sql_error= 0
--source include/wait_for_slave_sql_error.inc

--let $assert_text= Not everything that was read, was executed
--let $assert_cond= [SHOW SLAVE STATUS, Read_Master_Log_Pos, 1] > [SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1]
--source include/assert.inc

--let $assert_text= The max value for field 'a' is 2
--let $assert_cond= [SELECT MAX(a) AS Val FROM tm, Val, 1] = 2
--source include/assert.inc

--let $assert_text= The max value for field 'a' is 1
--let $assert_cond= [SELECT MAX(a) AS Val FROM ti, Val, 1] = 1
--source include/assert.inc

--source include/stop_slave.inc
set @@global.debug="-d,stop_replica_middle_group";
set @@global.debug="-d,incomplete_group_in_relay_log";

#
# clean-up
#

# the sql thread has an error, so reset replication state
--let $rpl_only_running_threads= 1
--source include/rpl_reset.inc

connection master;
drop table tm, ti;
--sync_slave_with_master