File: rpl_semi_sync_ack_thread.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 (260 lines) | stat: -rw-r--r-- 9,870 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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
###############################################################################
# WL#6630 Semisync separate acks collector
#
# In the worklog, a separate ack collector thread is added in semisync master
# plugin. This test verifys  the ack collector thread can works as expected.
#
# The thread is created when semisync master is enabled. and it is destroyed
# when semisync master is disabled.
################################################################################
--source include/not_valgrind.inc
--source include/not_group_replication_plugin.inc
--source include/have_debug.inc
--source include/have_debug_sync.inc

# server_1 is master, others are slaves.
--let $rpl_topology= 1->2, 1->3, 1->4
--source include/rpl_init.inc
--let $rpl_connection_name= server_1
--source include/rpl_connection.inc
# Suppress warning:
# "Semi-sync master failed on net_flush() before waiting for replica reply"
CALL mtr.add_suppression("Semi-sync source failed on net_flush().*");

--echo ####################################################################
--echo # Test Case: semisync master can be enabled and disabled sucessfully
--echo # without any live slave connection and also test ON, OFF can be set
--echo # more than once without problems.
--echo ####################################################################
--let $semisync_source_enabled= OFF
--source include/install_semisync_source.inc
SET GLOBAL rpl_semi_sync_source_enabled= ON;
SET GLOBAL rpl_semi_sync_source_enabled= ON;
SET GLOBAL rpl_semi_sync_source_enabled= OFF;
SET GLOBAL rpl_semi_sync_source_enabled= OFF;

--echo ####################################################################
--echo # Test Case: Semisync should work even semisync slaves are connected
--echo # before semisync master enabled.
--echo ####################################################################
CREATE TABLE t1(c1 INT) ENGINE=InnoDB;
--source include/rpl_sync.inc

--let $rpl_connection_name= server_2
--source include/rpl_connection.inc
--source include/install_semisync_replica.inc

--let $rpl_connection_name= server_1
--source include/rpl_connection.inc
SET GLOBAL rpl_semi_sync_source_enabled= ON;
--source extra/rpl_tests/rpl_semi_sync_ack_thread.inc

--echo ####################################################################
--echo # Test Case: Semisync should work when more than one semisync slaves
--echo # connectted.
--echo ####################################################################
--let $rpl_connection_name= server_3
--source include/rpl_connection.inc
--source include/install_semisync_replica.inc
--source extra/rpl_tests/rpl_semi_sync_ack_thread.inc

--let $rpl_connection_name= server_4
--source include/rpl_connection.inc
--source include/install_semisync_replica.inc

--source extra/rpl_tests/rpl_semi_sync_ack_thread.inc

--echo ###################################################################
--echo # Test Case: Semisync should work after semisync master is disabled
--echo # and enabled again.
--echo ###################################################################
--let $rpl_connection_name= server_1
--source include/rpl_connection.inc

SET GLOBAL rpl_semi_sync_source_enabled= OFF;
INSERT INTO t1 VALUES(0);
SET GLOBAL rpl_semi_sync_source_enabled= ON;
--source extra/rpl_tests/rpl_semi_sync_ack_thread.inc

--echo ###################################################################
--echo # Test Case: Semisync should still work after some semisync slaves
--echo # reconnected
--echo ###################################################################
--let $rpl_connection_name= server_2
--source include/rpl_connection.inc
--source include/stop_slave_io.inc
--source include/start_slave_io.inc

--source extra/rpl_tests/rpl_semi_sync_ack_thread.inc

--let $rpl_connection_name= server_3
--source include/rpl_connection.inc
--source include/stop_slave_io.inc
--source include/start_slave_io.inc

--source extra/rpl_tests/rpl_semi_sync_ack_thread.inc

--echo ###################################################################
--echo # Test Case: Semisync should still work after some semisync slaves
--echo # disconnected
--echo ###################################################################
--let $rpl_connection_name= server_2
--source include/rpl_connection.inc
--source include/uninstall_semisync_replica.inc

--source extra/rpl_tests/rpl_semi_sync_ack_thread.inc

--let $rpl_connection_name= server_3
--source include/rpl_connection.inc
--source include/uninstall_semisync_replica.inc

--source extra/rpl_tests/rpl_semi_sync_ack_thread.inc

--echo #####################################################################
--echo # Test Case: PS threads table includes ACK thread's status correctly.
--echo #####################################################################

--echo #
--echo # Status: Waiting for semi-sync ACK from replica
--echo #

# It may still in ack reading state, but it should change to ack waiting state.
--let $wait_condition= SELECT count(*) = 1 FROM performance_schema.threads WHERE PROCESSLIST_STATE = 'Waiting for semi-sync ACK from replica'
--source include/wait_condition.inc

--let $rpl_connection_name= server_1
--source include/rpl_connection.inc
SELECT name, type, processlist_state FROM performance_schema.threads
  WHERE name LIKE "%Ack_receiver";

--echo #
--echo # Coverage Test:
--echo # It should print an error to log if select() function returns -1
--echo #

SET @save_debug = @@GLOBAL.debug;
SET GLOBAL debug = '+d,rpl_semisync_simulate_select_error';

# wait enough time to guarantee that select() timeout happens
--sleep 2

# It can still receive ACK from semi-sync slave
INSERT INTO t1 VALUES(1);

SET GLOBAL debug = @save_debug;

--echo #
--echo # Status: Waiting for semisync slave to connect
--echo #
--let $rpl_connection_name= server_4
--source include/rpl_connection.inc
--source include/uninstall_semisync_replica.inc

--let $rpl_connection_name= server_1
--source include/rpl_connection.inc
# It guarantees semisync slave 5 is alrealdy unregistered from semisync master
CALL mtr.add_suppression("Timeout waiting for reply of binlog.*");
INSERT INTO t1 VALUES(1);
--save_master_pos

--let $rpl_connection_name= server_4
--source include/rpl_connection.inc
--sync_with_master

--let $rpl_connection_name= server_1
--source include/rpl_connection.inc
SELECT name, type, processlist_state FROM performance_schema.threads
  WHERE name LIKE "%Ack_receiver";

--echo #
--echo # Ack thread is stopped, it should be not in PS.threads table.
--echo #
SET GLOBAL rpl_semi_sync_source_enabled= OFF;

--let $assert_text= ack receiver thread is destroied
--let $assert_cond= count(*) = 0 FROM performance_schema.threads WHERE name LIKE "%Ack_receiver"
--source include/assert.inc

--echo ############################################
--echo # Test Case: Coverage test on error branches
--echo ############################################
SET @save_debug = @@GLOBAL.debug;
CALL mtr.add_suppression("Failed to start semi-sync ACK receiver thread.*");
CALL mtr.add_suppression("Failed to register replica to semi-sync ACK receiver thread.*");
CALL mtr.add_suppression("Failed to stop ack receiver thread on my_thread_join.*");
CALL mtr.add_suppression("Run function 'transmit_start' .* failed");

SET GLOBAL rpl_semi_sync_source_trace_level = 255;
--echo #
--echo # Failure on creating ack receiver thread
--echo #
SET GLOBAL debug = '+d,rpl_semisync_simulate_create_thread_failure';
SET GLOBAL rpl_semi_sync_source_enabled= ON;

--let $assert_variable_name= rpl_semi_sync_source_enabled
--let $assert_variable_value= 0
--source include/assert_variable.inc

--let $assert_text= ack receiver thread is destroied;
--let $assert_cond= count(*) = 0 FROM performance_schema.threads WHERE name LIKE "%Ack_receiver"
--source include/assert.inc

--echo #
--echo # Failure on stopping ack receive thread
--echo #

SET GLOBAL debug= @save_debug;
SET GLOBAL rpl_semi_sync_source_enabled= ON;

SET GLOBAL debug= '+d,rpl_semisync_simulate_thread_join_failure';
SET GLOBAL rpl_semi_sync_source_enabled= OFF;

--let $assert_variable_name= rpl_semi_sync_source_enabled
--let $assert_variable_value= 0
--source include/assert_variable.inc

--let $assert_text= ack receiver thread is destroied
--let $assert_cond= count(*) = 0 FROM performance_schema.threads WHERE name LIKE "%Ack_receiver"
--source include/assert.inc

--echo #
--echo # Failure on registering semisync slave
--echo #
SET GLOBAL debug= '-d,rpl_semisync_simulate_thread_join_failure';
SET GLOBAL debug= '+d,rpl_semisync_simulate_add_replica_failure';
SET GLOBAL rpl_semi_sync_source_enabled= ON;

--let $rpl_connection_name= server_2
--source include/rpl_connection.inc
--source include/stop_slave.inc
--let $save_retry_count= query_get_value(SHOW SLAVE STATUS, Master_Retry_Count, 1)
--let $save_retry_time= query_get_value(SHOW SLAVE STATUS, Connect_Retry, 1)
CHANGE REPLICATION SOURCE TO SOURCE_RETRY_COUNT = 1, SOURCE_CONNECT_RETRY = 5;

# Make IO thread hungs after connecting to master. So we can make sure it is
# stopped by add_slave_failure
SET @save_debug= @@GLOBAL.debug;
SET GLOBAL debug= '+d,dbug.before_get_SOURCE_UUID';
--source include/install_semisync_replica.inc

# Clear the debug point and signal IO thread to resume
SET GLOBAL debug= @save_debug;
SET debug_sync= 'now SIGNAL signal.get_source_uuid';

# It should be stopped by add_slave failure
--source include/wait_for_slave_io_to_stop.inc

eval CHANGE REPLICATION SOURCE TO SOURCE_RETRY_COUNT = $save_retry_count,
                      SOURCE_CONNECT_RETRY = $save_retry_time;

--source include/uninstall_semisync_replica.inc
--source include/start_slave_sql.inc

--let $rpl_connection_name= server_1
--source include/rpl_connection.inc
DROP TABLE t1;
--source include/rpl_sync.inc

SET GLOBAL debug= @save_debug;
--source include/uninstall_semisync_source.inc
--source include/rpl_end.inc