| 1 |
# ==== Purpose ==== |
| 2 |
# |
| 3 |
# This test case will test expected blockages when querying |
| 4 |
# performance_schema.log_status table. |
| 5 |
# |
| 6 |
# It will use 6 additional connections to the slave server to |
| 7 |
# send a statement that is expected to be blocked. Then, it will |
| 8 |
# proceed with the blockage by using debug instrumentation to |
| 9 |
# pause the thread generating the result before actually collecting |
| 10 |
# the log information. |
| 11 |
# |
| 12 |
# The test case will send all 6 statements expected to block, and will |
| 13 |
# wait until all report as doing something in performance_schema.threads. |
| 14 |
# |
| 15 |
# Finally, the test case will release the blockage and will wait until all |
| 16 |
# 6 statements to finish. |
| 17 |
# |
| 18 |
# The collected information will be verified. |
| 19 |
# |
| 20 |
# ==== Related Bugs and Worklogs ==== |
| 21 |
# |
| 22 |
# WL#9452: Log Position Lock |
| 23 |
# |
| 24 |
--source include/force_myisam_default.inc |
| 25 |
--source include/have_myisam.inc |
| 26 |
--source include/have_debug.inc |
| 27 |
--source include/have_debug_sync.inc |
| 28 |
# Test requires master-info-repository=TABLE, relay-log-info-repository=TABLE |
| 29 |
--source include/have_slave_repository_type_table.inc |
| 30 |
--let $rpl_extra_connections_per_server= 6 |
| 31 |
--source include/master-slave.inc |
| 32 |
|
| 33 |
--source include/rpl_connection_slave.inc |
| 34 |
--let $replica_checkpoint_period_value = `SELECT @@global.replica_checkpoint_period` |
| 35 |
SET @@GLOBAL.replica_checkpoint_period= 1; |
| 36 |
|
| 37 |
--source include/rpl_connection_master.inc |
| 38 |
# Create a table to store the data to be validated |
| 39 |
CREATE TABLE ils_copy ( |
| 40 |
uuid VARCHAR(36) PRIMARY KEY, |
| 41 |
master JSON NOT NULL, |
| 42 |
channels JSON NOT NULL, |
| 43 |
storage_engines JSON NOT NULL); |
| 44 |
|
| 45 |
CREATE TABLE t1_innodb (c1 INT); |
| 46 |
|
| 47 |
CREATE TABLE t2_myisam (c1 INT) ENGINE=MyISAM; |
| 48 |
|
| 49 |
--source include/sync_slave_sql_with_master.inc |
| 50 |
|
| 51 |
# Make server to pause when fully blocked |
| 52 |
--let $debug_point= pause_collecting_instance_logs_info |
| 53 |
--source include/add_debug_point.inc |
| 54 |
|
| 55 |
# Create a new channel, so we can test a non-empty channel name on results |
| 56 |
CHANGE REPLICATION SOURCE TO SOURCE_HOST = '127.0.0.1' FOR CHANNEL 'ch1'; |
| 57 |
|
| 58 |
# Suppression of error messages |
| 59 |
CALL mtr.add_suppression('Unsafe statement written to the binary log'); |
| 60 |
|
| 61 |
# Save current master binary log coordinates and gtid_executed |
| 62 |
--let $_saved_gtids= |
| 63 |
if (`SELECT @@GLOBAL.gtid_mode = "ON"`) |
| 64 |
{ |
| 65 |
--let $use_gtids= 1 |
| 66 |
} |
| 67 |
--source include/save_master_pos.inc |
| 68 |
|
| 69 |
# Save current slave relay log coordinates |
| 70 |
--let $relay_log_file= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1) |
| 71 |
--let $relay_log_pos= query_get_value(SHOW SLAVE STATUS, Relay_Log_Pos, 1) |
| 72 |
--let $ch1_relay_log_file= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 2) |
| 73 |
# As we do not start ch1, we cannot verify its positions accurately for this |
| 74 |
# test case purposes. That is fine as the objective is to test a non-empty |
| 75 |
# channel name. |
| 76 |
|
| 77 |
--source include/rpl_connection_slave1.inc |
| 78 |
FLUSH TABLES test.t2_myisam, performance_schema.threads WITH READ LOCK; |
| 79 |
|
| 80 |
--source include/rpl_connection_slave.inc |
| 81 |
# Save current InnoDB LSN and LSN_checkpoint before the collection |
| 82 |
--replace_regex /\n/<EOL>/ /.*<EOL>Last checkpoint at[[:space:]]*([0-9]+)<EOL>.*/\1/ |
| 83 |
--let $innodb_seis=`SHOW ENGINE INNODB STATUS` |
| 84 |
# Remove the "InnoDB" from the collected LSN_checkpoint info |
| 85 |
--let $innodb_lsn_checkpoint_before=`SELECT LTRIM(RIGHT('$innodb_seis', LENGTH('$innodb_seis') - 6))` |
| 86 |
--replace_regex /\n/<EOL>/ /.*<EOL>Log sequence number[[:space:]]*([0-9]+)<EOL>.*/\1/ |
| 87 |
--let $innodb_seis=`SHOW ENGINE INNODB STATUS` |
| 88 |
# Remove the "InnoDB" from the collected LSN info |
| 89 |
--let $innodb_lsn_before=`SELECT LTRIM(RIGHT('$innodb_seis', LENGTH('$innodb_seis') - 6))` |
| 90 |
|
| 91 |
# Collect the instance log status into ils_copy table |
| 92 |
--let $ils_dump= $MYSQLTEST_VARDIR/tmp/ils_$server_2_uuid |
| 93 |
--replace_result $ils_dump ILS_DUMP |
| 94 |
--send_eval SELECT * FROM performance_schema.log_status INTO OUTFILE '$ils_dump' |
| 95 |
|
| 96 |
--source include/rpl_connection_slave1.inc |
| 97 |
SET DEBUG_SYNC='now WAIT_FOR reached_collecting_instance_logs_info'; |
| 98 |
|
| 99 |
|
| 100 |
# No actions below show progress until |
| 101 |
# signaling "continue_collecting_instance_logs_info" in DEBUG_SYNC |
| 102 |
|
| 103 |
# No changes into binary log |
| 104 |
--let $rpl_connection_name= server_2_1 |
| 105 |
--source include/rpl_connection.inc |
| 106 |
--let $tid1=`SELECT CONNECTION_ID()` |
| 107 |
--send FLUSH LOCAL BINARY LOGS; |
| 108 |
|
| 109 |
# No changes into Gtid_state (GTID_EXECUTED) |
| 110 |
--let $rpl_connection_name= server_2_2 |
| 111 |
--source include/rpl_connection.inc |
| 112 |
--let $tid2=`SELECT CONNECTION_ID()` |
| 113 |
--send SET @@GLOBAL.gtid_purged = '+00000000-0000-0000-0000-000000000000:1-999' |
| 114 |
|
| 115 |
# No new channels can be created |
| 116 |
--let $rpl_connection_name= server_2_3 |
| 117 |
--source include/rpl_connection.inc |
| 118 |
--let $tid3=`SELECT CONNECTION_ID()` |
| 119 |
--send CHANGE REPLICATION SOURCE TO SOURCE_HOST='127.0.0.1' FOR CHANNEL 'ch2' |
| 120 |
|
| 121 |
# No existing channels can be removed |
| 122 |
--let $rpl_connection_name= server_2_4 |
| 123 |
--source include/rpl_connection.inc |
| 124 |
--let $tid4=`SELECT CONNECTION_ID()` |
| 125 |
--send RESET SLAVE ALL FOR CHANNEL 'ch1' |
| 126 |
|
| 127 |
# No changes into blocked storage engines (InnoDB) |
| 128 |
--let $rpl_connection_name= server_2_5 |
| 129 |
--source include/rpl_connection.inc |
| 130 |
--let $tid5=`SELECT CONNECTION_ID()` |
| 131 |
SET @sql_log_bin = 0; |
| 132 |
--send INSERT INTO t1_innodb VALUE (9) |
| 133 |
|
| 134 |
# No changes into blocked tables (MyISAM) |
| 135 |
--let $rpl_connection_name= server_2_6 |
| 136 |
--source include/rpl_connection.inc |
| 137 |
--let $tid6=`SELECT CONNECTION_ID()` |
| 138 |
SET @sql_log_bin = 0; |
| 139 |
--send INSERT INTO t2_myisam VALUE (9) |
| 140 |
|
| 141 |
# No changes into I/O thread relay log positions |
| 142 |
--source include/rpl_connection_master.inc |
| 143 |
FLUSH BINARY LOGS; |
| 144 |
INSERT INTO t1_innodb VALUES (1); |
| 145 |
INSERT INTO t2_myisam VALUES (1); |
| 146 |
FLUSH BINARY LOGS; |
| 147 |
INSERT INTO t1_innodb VALUES (2); |
| 148 |
INSERT INTO t2_myisam VALUES (2); |
| 149 |
|
| 150 |
# Give some time to all "--send" above |
| 151 |
--sleep 1 |
| 152 |
|
| 153 |
|
| 154 |
--source include/rpl_connection_slave1.inc |
| 155 |
--echo Wait until all threads expecting to be block be doing something |
| 156 |
--source include/rpl_connection_slave1.inc |
| 157 |
let $wait_condition= |
| 158 |
SELECT COUNT(*) = 6 FROM performance_schema.threads |
| 159 |
WHERE PROCESSLIST_ID IN ($tid1, $tid2, $tid3, $tid4, $tid5, $tid6) |
| 160 |
AND PROCESSLIST_STATE IS NOT NULL; |
| 161 |
--source include/wait_condition_or_abort.inc |
| 162 |
|
| 163 |
SET DEBUG_SYNC='now SIGNAL continue_collecting_instance_logs_info'; |
| 164 |
UNLOCK TABLES; |
| 165 |
|
| 166 |
--source include/rpl_connection_slave.inc |
| 167 |
--reap |
| 168 |
|
| 169 |
--replace_result $ils_dump ILS_DUMP |
| 170 |
--eval LOAD DATA INFILE '$ils_dump' INTO TABLE ils_copy |
| 171 |
|
| 172 |
--let $rpl_connection_name= server_2_1 |
| 173 |
--source include/rpl_connection.inc |
| 174 |
--reap |
| 175 |
|
| 176 |
--let $rpl_connection_name= server_2_2 |
| 177 |
--source include/rpl_connection.inc |
| 178 |
--reap |
| 179 |
|
| 180 |
--let $rpl_connection_name= server_2_3 |
| 181 |
--source include/rpl_connection.inc |
| 182 |
--reap |
| 183 |
|
| 184 |
--let $rpl_connection_name= server_2_4 |
| 185 |
--source include/rpl_connection.inc |
| 186 |
--reap |
| 187 |
|
| 188 |
--let $rpl_connection_name= server_2_5 |
| 189 |
--source include/rpl_connection.inc |
| 190 |
--reap |
| 191 |
|
| 192 |
--let $rpl_connection_name= server_2_6 |
| 193 |
--source include/rpl_connection.inc |
| 194 |
--reap |
| 195 |
|
| 196 |
--source include/rpl_connection_slave1.inc |
| 197 |
--echo Wait until all blocked threads are released and finish |
| 198 |
let $wait_condition= |
| 199 |
SELECT COUNT(*) = 6 FROM performance_schema.threads |
| 200 |
WHERE PROCESSLIST_ID IN ($tid1, $tid2, $tid3, $tid4, $tid5, $tid6) |
| 201 |
AND PROCESSLIST_STATE IS NULL; |
| 202 |
--source include/wait_condition_or_abort.inc |
| 203 |
|
| 204 |
# |
| 205 |
# Validate what was collected from performance_schema.log_status table |
| 206 |
# |
| 207 |
--source include/rpl_connection_slave.inc |
| 208 |
if ($rpl_debug) |
| 209 |
{ |
| 210 |
--query_vertical SELECT * FROM ils_copy |
| 211 |
} |
| 212 |
|
| 213 |
# Save current InnoDB LSN and LSN_checkpoint after the collection |
| 214 |
--replace_regex /\n/<EOL>/ /.*<EOL>Last checkpoint at[[:space:]]*([0-9]+)<EOL>.*/\1/ |
| 215 |
--let $innodb_seis=`SHOW ENGINE INNODB STATUS` |
| 216 |
# Remove the "InnoDB" from the collected LSN_checkpoint info |
| 217 |
--let $innodb_lsn_checkpoint_after=`SELECT LTRIM(RIGHT('$innodb_seis', LENGTH('$innodb_seis') - 6))` |
| 218 |
--replace_regex /\n/<EOL>/ /.*<EOL>Log sequence number[[:space:]]*([0-9]+)<EOL>.*/\1/ |
| 219 |
--let $innodb_seis=`SHOW ENGINE INNODB STATUS` |
| 220 |
# Remove the "InnoDB" from the collected LSN info |
| 221 |
--let $innodb_lsn_after=`SELECT LTRIM(RIGHT('$innodb_seis', LENGTH('$innodb_seis') - 6))` |
| 222 |
|
| 223 |
--let $assert_text= Collected server UUID is correct |
| 224 |
--let $ils_uuid= `SELECT uuid FROM ils_copy` |
| 225 |
--let $assert_cond= "$ils_uuid" = "$server_2_uuid" |
| 226 |
--source include/assert.inc |
| 227 |
|
| 228 |
--let $assert_text= Collected master binary log file name is correct |
| 229 |
--let $ils_master_file= `SELECT JSON_EXTRACT(master, "$.binary_log_file") FROM ils_copy` |
| 230 |
--let $assert_cond= $ils_master_file = "$_saved_file" |
| 231 |
--source include/assert.inc |
| 232 |
|
| 233 |
--let $assert_text= Collected master binary log file position is correct |
| 234 |
--let $ils_master_pos= `SELECT JSON_EXTRACT(master, "$.binary_log_position") FROM ils_copy` |
| 235 |
--let $assert_cond= $ils_master_pos = $_saved_pos |
| 236 |
--source include/assert.inc |
| 237 |
|
| 238 |
--let $assert_text= Collected master gtid_executed is correct |
| 239 |
--let $ils_gtid_executed= `SELECT JSON_EXTRACT(master, "$.gtid_executed") FROM ils_copy` |
| 240 |
--let $assert_cond= $ils_gtid_executed = "$_saved_gtids" |
| 241 |
--source include/assert.inc |
| 242 |
|
| 243 |
--let $assert_text= Collected default replication channel name is correct |
| 244 |
--let $ils_channel_name= `SELECT JSON_EXTRACT(channels, "$.channels[0].channel_name") FROM ils_copy` |
| 245 |
--let $assert_cond= $ils_channel_name = "" |
| 246 |
--source include/assert.inc |
| 247 |
|
| 248 |
--let $assert_text= Collected default replication channel relay log file name is correct |
| 249 |
--let $ils_relay_log_file= `SELECT JSON_EXTRACT(channels, "$.channels[0].relay_log_file") FROM ils_copy` |
| 250 |
--let $assert_cond= $ils_relay_log_file = "$relay_log_file" |
| 251 |
--source include/assert.inc |
| 252 |
|
| 253 |
--let $wait_condition= SELECT JSON_EXTRACT(channels, "$.channels[0].relay_log_position")=$relay_log_pos FROM ils_copy |
| 254 |
--source include/wait_condition_or_abort.inc |
| 255 |
|
| 256 |
--let $assert_text= Collected default replication channel relay log file position is correct |
| 257 |
--let $ils_relay_log_pos= `SELECT JSON_EXTRACT(channels, "$.channels[0].relay_log_position") FROM ils_copy` |
| 258 |
--let $assert_cond= $ils_relay_log_pos = $relay_log_pos |
| 259 |
--source include/assert.inc |
| 260 |
|
| 261 |
--let $assert_text= Collected replication channel name for ch1 is correct |
| 262 |
--let $ils_ch1_channel_name= `SELECT JSON_EXTRACT(channels, "$.channels[1].channel_name") FROM ils_copy` |
| 263 |
--let $assert_cond= $ils_ch1_channel_name = "ch1" |
| 264 |
--source include/assert.inc |
| 265 |
|
| 266 |
--let $assert_text= Collected replication channel relay log file name for ch1 is correct |
| 267 |
--let $ils_ch1_relay_log_file= `SELECT JSON_EXTRACT(channels, "$.channels[1].relay_log_file") FROM ils_copy` |
| 268 |
--let $assert_cond= $ils_ch1_relay_log_file = "$ch1_relay_log_file" |
| 269 |
--source include/assert.inc |
| 270 |
|
| 271 |
--let $assert_text= There is no other channel information collected (no ch2) |
| 272 |
--let $ils_ch2= `SELECT JSON_EXTRACT(channels, "$.channels[2].channel_name") IS NULL FROM ils_copy` |
| 273 |
--let $assert_cond= $ils_ch2 = 1 |
| 274 |
--source include/assert.inc |
| 275 |
|
| 276 |
--let $assert_text= Collected InnoDB LSN is in correct boundaries |
| 277 |
--let $ils_innodb_lsn= `SELECT JSON_EXTRACT(storage_engines, "$.InnoDB.LSN") FROM ils_copy` |
| 278 |
--let $assert_cond= $innodb_lsn_after >= $ils_innodb_lsn AND $ils_innodb_lsn >= $innodb_lsn_before |
| 279 |
--source include/assert.inc |
| 280 |
|
| 281 |
--let $assert_text= Collected InnoDB LSN_checkpoint is in correct boundaries |
| 282 |
--let $ils_innodb_lsn_checkpoint = `SELECT JSON_EXTRACT(storage_engines, "$.InnoDB.LSN_checkpoint") FROM ils_copy` |
| 283 |
--let $assert_cond= $innodb_lsn_checkpoint_after >= $ils_innodb_lsn_checkpoint AND $ils_innodb_lsn_checkpoint >= $innodb_lsn_checkpoint_before |
| 284 |
--source include/assert.inc |
| 285 |
|
| 286 |
|
| 287 |
# Cleanup |
| 288 |
--source include/rpl_connection_slave.inc |
| 289 |
--source include/remove_debug_point.inc |
| 290 |
--replace_result $replica_checkpoint_period_value REPLICA_CHECKPOINT_PERIOD |
| 291 |
--eval SET @@GLOBAL.replica_checkpoint_period= $replica_checkpoint_period_value |
| 292 |
RESET SLAVE ALL FOR CHANNEL 'ch2'; |
| 293 |
--remove_file $ils_dump |
| 294 |
|
| 295 |
--source include/rpl_connection_master.inc |
| 296 |
DROP TABLE ils_copy, t1_innodb, t2_myisam; |
| 297 |
|
| 298 |
--source include/rpl_end.inc |