File: rpl_semi_sync_cond_var_per_thd.test

package info (click to toggle)
mariadb 1%3A11.8.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 772,520 kB
  • sloc: ansic: 2,414,714; cpp: 1,791,394; asm: 381,336; perl: 62,905; sh: 49,647; pascal: 40,897; java: 39,363; python: 20,791; yacc: 20,432; sql: 17,907; xml: 12,344; ruby: 8,544; cs: 6,542; makefile: 6,145; ada: 1,879; lex: 1,193; javascript: 996; objc: 80; tcl: 73; awk: 46; php: 22
file content (321 lines) | stat: -rw-r--r-- 11,140 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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
#
#   This test ensures that, when using semi-sync with the wait_point
# AFTER_COMMIT, each thread awaiting an ACK is only woken up when its ACK (or
# an ACK for a later commit in binlog) has been received from the slave.
#
#   Prior to MDEV-33551, all threads would be woken up for each ACK received,
# leading to large slowdowns, as each thread would check if the ACK was for it
# in mutual exclusion from the others.
#
#   To ensure this, a debug-build-only log warning is added into
# Repl_semi_sync_master::commit_trx() at wakeup time, which will complain if
# the awoken thread's binlog wait coordinates are after the coordinate of the
# last ACK coordinates. Then, we use binlog group commit to commit a series of
# transactions, such that each will await an ACK concurrently. After all
# transactions have been finished (i.e. ACKed and committed), we check the log
# for the expected absence of the added debug warning message.
#
#
# References:
#   MDEV-33551: Semi-sync Wait Point AFTER_COMMIT Slow on Workloads with Heavy
#               Concurrency
#   MDEV-34122: Assertion `entry' failed in Active_tranx::assert_thd_is_waiter
#
--source include/have_binlog_format_row.inc
--source include/have_innodb.inc
--source include/have_debug.inc
--source include/have_debug_sync.inc
--source include/master-slave.inc

--connection master
call mtr.add_suppression("Got an error writing communication packets");
call mtr.add_suppression("Got an error reading communication packets");
call mtr.add_suppression("Could not read packet:.* vio_errno: 1158");
call mtr.add_suppression("Could not write packet:.* vio_errno: 1160");
set @save_semi_sync_master_enabled= @@global.rpl_semi_sync_master_enabled;
set @save_semi_sync_wp= @@global.rpl_semi_sync_master_wait_point;
set @save_bgc_count= @@global.binlog_commit_wait_count;
set @save_bgc_usec= @@global.binlog_commit_wait_usec;
set @old_master_wait_point= @@global.rpl_semi_sync_master_wait_point;
set @old_master_wait_no_slave= @@global.rpl_semi_sync_master_wait_no_slave;
set @save_debug_dbug= @@global.debug_dbug;
set @@global.binlog_commit_wait_count=3;
set @@global.binlog_commit_wait_usec=10000000;
set @@global.debug_dbug="+d,testing_cond_var_per_thd";
set @@global.rpl_semi_sync_master_enabled= 1;
set @@global.rpl_semi_sync_master_wait_point= AFTER_COMMIT;

--echo # Ensure semi-sync is on
--connection slave
set @save_semi_sync_slave_enabled= @@global.rpl_semi_sync_master_enabled;
--source include/stop_slave.inc
set @@global.rpl_semi_sync_slave_enabled=1;
--source include/start_slave.inc

let $status_var= rpl_semi_sync_slave_status;
let $status_var_value= ON;
source include/wait_for_status_var.inc;

--connection master
let $status_var= rpl_semi_sync_master_status;
let $status_var_value= ON;
source include/wait_for_status_var.inc;

--echo # Create three transactions to binlog group commit together
--connection master
--send create table t1 (a int)
--connection server_1
--send create table t2 (a int)
--connection default
--send create table t3 (a int)

--connection master
--reap
--connection server_1
--reap
--connection default
--reap

--let $assert_text= Check that there is no 'Thread awaiting semi-sync ACK was awoken before its ACK' warning in error log.
--let $assert_select=Thread awaiting semi-sync ACK was awoken before its ACK
--let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.1.err
--let $assert_count= 0
--let $assert_only_after=CURRENT_TEST
--source include/assert_grep.inc

--sync_slave_with_master


--echo #
--echo # Cleanup
--connection master
set @@global.binlog_commit_wait_count=@save_bgc_count;
set @@global.binlog_commit_wait_usec=@save_bgc_usec;
set @@global.debug_dbug=@save_debug_dbug;
drop table t1, t2, t3;
--sync_slave_with_master


--echo #
--echo # MDEV-34122
--echo # If semi-sync is switched off then on while a transaction is
--echo # in-between binlogging and waiting for an ACK, ensure that the
--echo # transaction skips the wait altogether (otherwise it would time-out).
--echo # Note that prior to MDEV-34122, there was a debug assertion that would
--echo # trigger if the transaction tried to wait but could not receive an ACK
--echo # signal.

--echo #
--echo # MDEV-34122.a: Test wait_point = AFTER_SYNC
--echo # Here, debug_sync is used to pause the leader thread between reporting
--echo # the binlogging to semi-sync, and starting the wait for ACK; and during
--echo # this pause, semi-sync is manually switched off and on.


--connection master
set @@global.rpl_semi_sync_master_wait_point= AFTER_SYNC;
set @@global.rpl_semi_sync_master_wait_no_slave= 1;
--eval set @@global.debug_dbug="+d,semisync_log_skip_trx_wait"

--echo # Waiting for semi-sync to turn on..
let $status_var= rpl_semi_sync_master_status;
let $status_var_value= ON;
source include/wait_for_status_var.inc;
--connection slave
let $status_var= rpl_semi_sync_slave_status;
let $status_var_value= ON;
source include/wait_for_status_var.inc;

--connection master
create table t (a int) engine=innodb;
--sync_slave_with_master

--echo # Wait no slave is on, so we don't need to slave on to wait for the
--echo # ACK, and this way we guarantee the ACK doesn't come, so we can verify
--echo # the informational message is displayed
--connection slave
--source include/stop_slave.inc
# Also kill the master-side dump thread so it doesn't try and send an event
# over a dead connection (potentially resulting in an error in the log)
--connection master
--source include/kill_binlog_dump_threads.inc

--connection server_1
start transaction;
insert into t values (0);
set debug_sync= "commit_after_release_LOCK_log SIGNAL trx_binlogged WAIT_FOR continue_commit";
--send commit

--connection master
set debug_sync= "now WAIT_FOR trx_binlogged";

--echo # Switching semi-sync off/on
set @@global.rpl_semi_sync_master_enabled= 0;
set @@global.rpl_semi_sync_master_enabled= 1;
let $status_var= rpl_semi_sync_master_status;
let $status_var_value= ON;
source include/wait_for_status_var.inc;

--echo # Resuming transaction to await ACK
set debug_sync= "now SIGNAL continue_commit";

--connection server_1
--reap

--let $assert_text= Ensure error log shows that transaction is skipping its semi-sync wait
--let $assert_select=Skipping semi-sync wait for transaction
--let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.1.err
--let $assert_count= 1
--let $assert_only_after=CURRENT_TEST
--source include/assert_grep.inc

--echo # Cleanup
--connection slave
--source include/start_slave.inc

--connection master
drop table t;
--sync_slave_with_master


--echo #
--echo # MDEV-34122.b: Test wait_point = AFTER_COMMIT
--echo # Here, use a transaction with a non-transactional statement to write to
--echo # the binlog directly, and turn off/on semi-sync before committing the
--echo # transaction.

--connection master
set @@global.rpl_semi_sync_master_wait_point= AFTER_COMMIT;

--echo # Waiting for semi-sync to turn on..
let $status_var= rpl_semi_sync_master_status;
let $status_var_value= ON;
source include/wait_for_status_var.inc;
--connection slave
let $status_var= rpl_semi_sync_slave_status;
let $status_var_value= ON;
source include/wait_for_status_var.inc;

--connection master
create table tn (a int) engine=Aria;
start transaction;
insert into tn values (NULL);
set @@global.rpl_semi_sync_master_enabled= 0;
set @@global.rpl_semi_sync_master_enabled= 1;
commit;

--echo # Cleanup
--connection master
drop table tn;
set @@global.debug_dbug=@save_debug_dbug;


--echo #
--echo # MDEV-36934
--echo # The server could indefinitely hang due to a memory leak which tried to
--echo # pthread signal on a destroyed condition variable. In effect, no
--echo # connections could commit transactions because there would be a thread
--echo # stuck on a never-returning call to pthread_cond_signal() while
--echo # holding Repl_semi_sync_master::LOCK_log.

--connection master
set @@global.rpl_semi_sync_master_wait_point= AFTER_COMMIT;
set @@global.rpl_semi_sync_master_wait_no_slave= 0;

--echo # Ensure servers are in proper state
--connection master
let $status_var= rpl_semi_sync_master_status;
let $status_var_value= ON;
source include/wait_for_status_var.inc;
--connection slave
let $status_var= rpl_semi_sync_slave_status;
let $status_var_value= ON;
source include/wait_for_status_var.inc;

--echo # Test case initial set-up
--connection master
create table t_36934 (a int) engine=innodb;
--source include/save_master_gtid.inc
--connection slave
--source include/sync_with_master_gtid.inc

--echo # Pause the user transaction before inserting into Active_tranx
--connect(user_con,localhost,root,,)
SET debug_sync= 'semisync_at_write_tranx_in_binlog SIGNAL at_write_tranx_in_binlog WAIT_FOR resume_write_tranx_in_binlog';
--send insert into t_36934 values (1)

--connection server_1
set debug_sync="now wait_for at_write_tranx_in_binlog";

--echo # Disconnect the slave (note that the binlog dump thread won't yet be
--echo # notified of a binlog update from the last transaction, so the slave
--echo # should neither receiver nor ACK the transaction).
--connection slave
--source include/stop_slave.inc

--echo # Waiting for master to realize the slave has disconnected..
--connection server_1
let $status_var= rpl_semi_sync_master_clients;
let $status_var_value= 0;
source include/wait_for_status_var.inc;
--echo # ..done

--echo # Resuming transaction (it will exit commit_trx early without waiting)
set debug_sync="now signal resume_write_tranx_in_binlog";

--connection user_con
--reap
--let $user_con_tid= `SELECT connection_id()`
--disconnect user_con
--source include/wait_until_disconnected.inc

--echo # Force delete the user thread (FLUSH THREADS ensures the thread won't
--echo # stay in the thread cache)
--connection master
FLUSH THREADS;

--echo # BUG: Re-connect slave. MDEV-36934 reports that the master would hang
--echo # when the slave would re-connect and try to ACK the last transaction
--echo # who's thread has been deleted
--connection slave
--source include/start_slave.inc

--echo # Try to commit another transaction (prior to MDEV-36934 fixes, this
--echo # would hang indefinitely)
--connection master
set debug_sync="RESET";
--send insert into t_36934 values (2)

--connection server_1
--echo # Waiting 30s for last query to complete..
--let $wait_timeout= 30
--let $wait_condition= SELECT count(*)=0 FROM information_schema.processlist WHERE info LIKE 'insert into t_36934%';
--source include/wait_condition.inc

# Variable `success` is set by wait_condition.inc
if (!$success)
{
  --echo # ..error
  --die Query is hung
}

--connection master
--reap
--echo # ..done


--echo # Cleanup
--connection master
set @@global.rpl_semi_sync_master_wait_point= @old_master_wait_point;
set @@global.rpl_semi_sync_master_wait_no_slave= @old_master_wait_no_slave;
set @@global.debug_dbug=@save_debug_dbug;
set @@global.rpl_semi_sync_master_enabled= @save_semi_sync_master_enabled;
set @@global.rpl_semi_sync_master_wait_point= @save_semi_sync_wp;
drop table t_36934;

--connection slave
--source include/stop_slave.inc
set @@global.rpl_semi_sync_slave_enabled= @save_semi_sync_slave_enabled;
--source include/start_slave.inc

--source include/rpl_end.inc