File: rpl_perfschema_log_status_blockage.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 (298 lines) | stat: -rw-r--r-- 11,520 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
# ==== Purpose ====
#
# This test case will test expected blockages when querying
# performance_schema.log_status table.
#
# It will use 6 additional connections to the slave server to
# send a statement that is expected to be blocked. Then, it will
# proceed with the blockage by using debug instrumentation to
# pause the thread generating the result before actually collecting
# the log information.
#
# The test case will send all 6 statements expected to block, and will
# wait until all report as doing something in performance_schema.threads.
#
# Finally, the test case will release the blockage and will wait until all
# 6 statements to finish.
#
# The collected information will be verified.
#
# ==== Related Bugs and Worklogs ====
#
# WL#9452: Log Position Lock
#
--source include/force_myisam_default.inc
--source include/have_myisam.inc
--source include/have_debug.inc
--source include/have_debug_sync.inc
# Test requires master-info-repository=TABLE, relay-log-info-repository=TABLE
--source include/have_slave_repository_type_table.inc
--let $rpl_extra_connections_per_server= 6
--source include/master-slave.inc

--source include/rpl_connection_slave.inc
--let $replica_checkpoint_period_value = `SELECT @@global.replica_checkpoint_period`
SET @@GLOBAL.replica_checkpoint_period= 1;

--source include/rpl_connection_master.inc
# Create a table to store the data to be validated
CREATE TABLE ils_copy (
  uuid VARCHAR(36) PRIMARY KEY,
  master JSON NOT NULL,
  channels JSON NOT NULL,
  storage_engines JSON NOT NULL);

CREATE TABLE t1_innodb (c1 INT);

CREATE TABLE t2_myisam (c1 INT) ENGINE=MyISAM;

--source include/sync_slave_sql_with_master.inc

# Make server to pause when fully blocked
--let $debug_point= pause_collecting_instance_logs_info
--source include/add_debug_point.inc

# Create a new channel, so we can test a non-empty channel name on results
CHANGE REPLICATION SOURCE TO SOURCE_HOST = '127.0.0.1' FOR CHANNEL 'ch1';

# Suppression of error messages
CALL mtr.add_suppression('Unsafe statement written to the binary log');

# Save current master binary log coordinates and gtid_executed
--let $_saved_gtids=
if (`SELECT @@GLOBAL.gtid_mode = "ON"`)
{
  --let $use_gtids= 1
}
--source include/save_master_pos.inc

# Save current slave relay log coordinates
--let $relay_log_file= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1)
--let $relay_log_pos= query_get_value(SHOW SLAVE STATUS, Relay_Log_Pos, 1)
--let $ch1_relay_log_file= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 2)
# As we do not start ch1, we cannot verify its positions accurately for this
# test case purposes. That is fine as the objective is to test a non-empty
# channel name.

--source include/rpl_connection_slave1.inc
FLUSH TABLES test.t2_myisam, performance_schema.threads WITH READ LOCK;

--source include/rpl_connection_slave.inc
# Save current InnoDB LSN and LSN_checkpoint before the collection
--replace_regex /\n/<EOL>/ /.*<EOL>Last checkpoint at[[:space:]]*([0-9]+)<EOL>.*/\1/
--let $innodb_seis=`SHOW ENGINE INNODB STATUS`
# Remove the "InnoDB" from the collected LSN_checkpoint info
--let $innodb_lsn_checkpoint_before=`SELECT LTRIM(RIGHT('$innodb_seis', LENGTH('$innodb_seis') - 6))`
--replace_regex /\n/<EOL>/ /.*<EOL>Log sequence number[[:space:]]*([0-9]+)<EOL>.*/\1/
--let $innodb_seis=`SHOW ENGINE INNODB STATUS`
# Remove the "InnoDB" from the collected LSN info
--let $innodb_lsn_before=`SELECT LTRIM(RIGHT('$innodb_seis', LENGTH('$innodb_seis') - 6))`

# Collect the instance log status into ils_copy table
--let $ils_dump= $MYSQLTEST_VARDIR/tmp/ils_$server_2_uuid
--replace_result $ils_dump ILS_DUMP
--send_eval SELECT * FROM performance_schema.log_status INTO OUTFILE '$ils_dump'

--source include/rpl_connection_slave1.inc
SET DEBUG_SYNC='now WAIT_FOR reached_collecting_instance_logs_info';


# No actions below show progress until
# signaling "continue_collecting_instance_logs_info" in DEBUG_SYNC

# No changes into binary log
--let $rpl_connection_name= server_2_1
--source include/rpl_connection.inc
--let $tid1=`SELECT CONNECTION_ID()`
--send FLUSH LOCAL BINARY LOGS;

# No changes into Gtid_state (GTID_EXECUTED)
--let $rpl_connection_name= server_2_2
--source include/rpl_connection.inc
--let $tid2=`SELECT CONNECTION_ID()`
--send SET @@GLOBAL.gtid_purged = '+00000000-0000-0000-0000-000000000000:1-999'

# No new channels can be created
--let $rpl_connection_name= server_2_3
--source include/rpl_connection.inc
--let $tid3=`SELECT CONNECTION_ID()`
--send CHANGE REPLICATION SOURCE TO SOURCE_HOST='127.0.0.1' FOR CHANNEL 'ch2'

# No existing channels can be removed
--let $rpl_connection_name= server_2_4
--source include/rpl_connection.inc
--let $tid4=`SELECT CONNECTION_ID()`
--send RESET SLAVE ALL FOR CHANNEL 'ch1'

# No changes into blocked storage engines (InnoDB)
--let $rpl_connection_name= server_2_5
--source include/rpl_connection.inc
--let $tid5=`SELECT CONNECTION_ID()`
SET @sql_log_bin = 0;
--send INSERT INTO t1_innodb VALUE (9)

# No changes into blocked tables (MyISAM)
--let $rpl_connection_name= server_2_6
--source include/rpl_connection.inc
--let $tid6=`SELECT CONNECTION_ID()`
SET @sql_log_bin = 0;
--send INSERT INTO t2_myisam VALUE (9)

# No changes into I/O thread relay log positions
--source include/rpl_connection_master.inc
FLUSH BINARY LOGS;
INSERT INTO t1_innodb VALUES (1);
INSERT INTO t2_myisam VALUES (1);
FLUSH BINARY LOGS;
INSERT INTO t1_innodb VALUES (2);
INSERT INTO t2_myisam VALUES (2);

# Give some time to all "--send" above
--sleep 1


--source include/rpl_connection_slave1.inc
--echo Wait until all threads expecting to be block be doing something
--source include/rpl_connection_slave1.inc
let $wait_condition=
  SELECT COUNT(*) = 6 FROM performance_schema.threads
  WHERE PROCESSLIST_ID IN ($tid1, $tid2, $tid3, $tid4, $tid5, $tid6)
  AND PROCESSLIST_STATE IS NOT NULL;
--source include/wait_condition_or_abort.inc

SET DEBUG_SYNC='now SIGNAL continue_collecting_instance_logs_info';
UNLOCK TABLES;

--source include/rpl_connection_slave.inc
--reap

--replace_result $ils_dump ILS_DUMP
--eval LOAD DATA INFILE '$ils_dump' INTO TABLE ils_copy

--let $rpl_connection_name= server_2_1
--source include/rpl_connection.inc
--reap

--let $rpl_connection_name= server_2_2
--source include/rpl_connection.inc
--reap

--let $rpl_connection_name= server_2_3
--source include/rpl_connection.inc
--reap

--let $rpl_connection_name= server_2_4
--source include/rpl_connection.inc
--reap

--let $rpl_connection_name= server_2_5
--source include/rpl_connection.inc
--reap

--let $rpl_connection_name= server_2_6
--source include/rpl_connection.inc
--reap

--source include/rpl_connection_slave1.inc
--echo Wait until all blocked threads are released and finish
let $wait_condition=
  SELECT COUNT(*) = 6 FROM performance_schema.threads
  WHERE PROCESSLIST_ID IN ($tid1, $tid2, $tid3, $tid4, $tid5, $tid6)
  AND PROCESSLIST_STATE IS NULL;
--source include/wait_condition_or_abort.inc

#
# Validate what was collected from performance_schema.log_status table
#
--source include/rpl_connection_slave.inc
if ($rpl_debug)
{
  --query_vertical SELECT * FROM ils_copy
}

# Save current InnoDB LSN and LSN_checkpoint after the collection
--replace_regex /\n/<EOL>/ /.*<EOL>Last checkpoint at[[:space:]]*([0-9]+)<EOL>.*/\1/
--let $innodb_seis=`SHOW ENGINE INNODB STATUS`
# Remove the "InnoDB" from the collected LSN_checkpoint info
--let $innodb_lsn_checkpoint_after=`SELECT LTRIM(RIGHT('$innodb_seis', LENGTH('$innodb_seis') - 6))`
--replace_regex /\n/<EOL>/ /.*<EOL>Log sequence number[[:space:]]*([0-9]+)<EOL>.*/\1/
--let $innodb_seis=`SHOW ENGINE INNODB STATUS`
# Remove the "InnoDB" from the collected LSN info
--let $innodb_lsn_after=`SELECT LTRIM(RIGHT('$innodb_seis', LENGTH('$innodb_seis') - 6))`

--let $assert_text= Collected server UUID is correct
--let $ils_uuid= `SELECT uuid FROM ils_copy`
--let $assert_cond= "$ils_uuid" = "$server_2_uuid"
--source include/assert.inc

--let $assert_text= Collected master binary log file name is correct
--let $ils_master_file= `SELECT JSON_EXTRACT(master, "$.binary_log_file") FROM ils_copy`
--let $assert_cond= $ils_master_file = "$_saved_file"
--source include/assert.inc

--let $assert_text= Collected master binary log file position is correct
--let $ils_master_pos= `SELECT JSON_EXTRACT(master, "$.binary_log_position") FROM ils_copy`
--let $assert_cond= $ils_master_pos = $_saved_pos
--source include/assert.inc

--let $assert_text= Collected master gtid_executed is correct
--let $ils_gtid_executed= `SELECT JSON_EXTRACT(master, "$.gtid_executed") FROM ils_copy`
--let $assert_cond= $ils_gtid_executed = "$_saved_gtids"
--source include/assert.inc

--let $assert_text= Collected default replication channel name is correct
--let $ils_channel_name= `SELECT JSON_EXTRACT(channels, "$.channels[0].channel_name") FROM ils_copy`
--let $assert_cond= $ils_channel_name = ""
--source include/assert.inc

--let $assert_text= Collected default replication channel relay log file name is correct
--let $ils_relay_log_file= `SELECT JSON_EXTRACT(channels, "$.channels[0].relay_log_file") FROM ils_copy`
--let $assert_cond= $ils_relay_log_file = "$relay_log_file"
--source include/assert.inc

--let $wait_condition= SELECT JSON_EXTRACT(channels, "$.channels[0].relay_log_position")=$relay_log_pos FROM ils_copy
--source include/wait_condition_or_abort.inc

--let $assert_text= Collected default replication channel relay log file position is correct
--let $ils_relay_log_pos= `SELECT JSON_EXTRACT(channels, "$.channels[0].relay_log_position") FROM ils_copy`
--let $assert_cond= $ils_relay_log_pos = $relay_log_pos
--source include/assert.inc

--let $assert_text= Collected replication channel name for ch1 is correct
--let $ils_ch1_channel_name= `SELECT JSON_EXTRACT(channels, "$.channels[1].channel_name") FROM ils_copy`
--let $assert_cond= $ils_ch1_channel_name = "ch1"
--source include/assert.inc

--let $assert_text= Collected replication channel relay log file name for ch1 is correct
--let $ils_ch1_relay_log_file= `SELECT JSON_EXTRACT(channels, "$.channels[1].relay_log_file") FROM ils_copy`
--let $assert_cond= $ils_ch1_relay_log_file = "$ch1_relay_log_file"
--source include/assert.inc

--let $assert_text= There is no other channel information collected (no ch2)
--let $ils_ch2= `SELECT JSON_EXTRACT(channels, "$.channels[2].channel_name") IS NULL FROM ils_copy`
--let $assert_cond= $ils_ch2 = 1
--source include/assert.inc

--let $assert_text= Collected InnoDB LSN is in correct boundaries
--let $ils_innodb_lsn= `SELECT JSON_EXTRACT(storage_engines, "$.InnoDB.LSN") FROM ils_copy`
--let $assert_cond= $innodb_lsn_after >= $ils_innodb_lsn AND $ils_innodb_lsn >= $innodb_lsn_before
--source include/assert.inc

--let $assert_text= Collected InnoDB LSN_checkpoint is in correct boundaries
--let $ils_innodb_lsn_checkpoint = `SELECT JSON_EXTRACT(storage_engines, "$.InnoDB.LSN_checkpoint") FROM ils_copy`
--let $assert_cond= $innodb_lsn_checkpoint_after >= $ils_innodb_lsn_checkpoint AND $ils_innodb_lsn_checkpoint >= $innodb_lsn_checkpoint_before
--source include/assert.inc


# Cleanup
--source include/rpl_connection_slave.inc
--source include/remove_debug_point.inc
--replace_result $replica_checkpoint_period_value REPLICA_CHECKPOINT_PERIOD
--eval SET @@GLOBAL.replica_checkpoint_period= $replica_checkpoint_period_value
RESET SLAVE ALL FOR CHANNEL 'ch2';
--remove_file $ils_dump

--source include/rpl_connection_master.inc
DROP TABLE ils_copy, t1_innodb, t2_myisam;

--source include/rpl_end.inc