| 1 |
# ==== Purpose ==== |
| 2 |
# |
| 3 |
# This test validates that no info is persisted in the applier metadata repository |
| 4 |
# |
| 5 |
# ==== Requirements ==== |
| 6 |
# |
| 7 |
# For the applier metadata repository: |
| 8 |
# R1. When CHANGE REPLICATION SOURCE is executed the repository fields are persisted |
| 9 |
# R2. Position information updated when a event is applied is not persisted in the repository |
| 10 |
# R3. Stop replication commands do not make the server persist information in the repository |
| 11 |
# R4. Start replication commands do not make the server persist information in the repository |
| 12 |
# R5. Killing the applier does not make the server persist information in the repository |
| 13 |
# R6: RESET REPLICA persists repository information after reseting it |
| 14 |
# |
| 15 |
# ==== Implementation ==== |
| 16 |
# |
| 17 |
# 1. Create a table on the source and replicate it. |
| 18 |
# Set the value of sync_source_info to 1 so the repo is always synced |
| 19 |
# Check the repo shows the same value as SHOW REPLICA STATUS |
| 20 |
# 2. Stop replication and make the channel use GTID_ONLY=1 |
| 21 |
# Start replication and add some values to the table. |
| 22 |
# Check the repo shows the old values in relation to SHOW REPLICA STATUS |
| 23 |
# 3. Stop replication |
| 24 |
# Check the repo still shows the old values in relation to SHOW REPLICA STATUS |
| 25 |
# 4. Start replication again |
| 26 |
# Check the repo still shows the old values in relation to SHOW REPLICA STATUS |
| 27 |
# 5. Kill the SQL thread |
| 28 |
# Check the repo still shows the old values in relation to SHOW REPLICA STATUS |
| 29 |
# 6. Change a replication connection setting with CHANGE REPLICATION SOURCE |
| 30 |
# Check the repo still now as the same value in relation to SHOW REPLICA STATUS |
| 31 |
# 7. Restart the replica server |
| 32 |
# Check the repo still shows the old values |
| 33 |
# 8. Add some values and check the repo is again stale |
| 34 |
# Execute a RESET REPLICA command |
| 35 |
# Check the repo persisted the reset position |
| 36 |
# 9. Check RESET REPLICA ALL removes all the information |
| 37 |
# 10. Cleanup |
| 38 |
# |
| 39 |
# ==== References ==== |
| 40 |
# |
| 41 |
# WL#7491: GTID-based replication applier recovery and positioning |
| 42 |
# |
| 43 |
|
| 44 |
--source include/have_binlog_format_row.inc |
| 45 |
--source include/have_slave_repository_type_table.inc |
| 46 |
--source include/not_rpl_gtid_only.inc |
| 47 |
|
| 48 |
# This test compares source log positions between source memory and replica |
| 49 |
# repositories. Ensure synchronization of the source log positions |
| 50 |
# between source and replica memory regardless of GTIDs. |
| 51 |
--let $ignore_gtids_on_sync= 1 |
| 52 |
|
| 53 |
--source include/master-slave.inc |
| 54 |
|
| 55 |
--echo # |
| 56 |
--echo # 1. Create a table on the source and replicate it. |
| 57 |
--echo # Check the repo shows the same value as SHOW REPLICA STATUS |
| 58 |
|
| 59 |
--source include/rpl_connection_slave.inc |
| 60 |
|
| 61 |
# Reduce this to a minimum |
| 62 |
--let $replica_checkpoint_period_value = `SELECT @@global.replica_checkpoint_period` |
| 63 |
SET @@GLOBAL.replica_checkpoint_period= 1; |
| 64 |
|
| 65 |
--source include/rpl_connection_master.inc |
| 66 |
|
| 67 |
CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY); |
| 68 |
|
| 69 |
INSERT INTO t1 VALUES (1); |
| 70 |
|
| 71 |
--source include/sync_slave_sql_with_master.inc |
| 72 |
|
| 73 |
--let $srs_relay_log_pos = query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Relay_Log_Pos, 1) |
| 74 |
--let $table_relay_log_pos = `SELECT Relay_log_pos FROM mysql.slave_relay_log_info` |
| 75 |
--let $assert_cond= [ SELECT $srs_relay_log_pos = $table_relay_log_pos ] |
| 76 |
--let $assert_text= The repository has the lastest position |
| 77 |
--source include/assert.inc |
| 78 |
|
| 79 |
--let $srs_relay_log_name = query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Relay_Log_File, 1) |
| 80 |
--let $table_relay_log_name = `SELECT Relay_log_name FROM mysql.slave_relay_log_info` |
| 81 |
|
| 82 |
# As the table string may contain path characters in it, we use the locate function |
| 83 |
--let $assert_cond= [ SELECT LOCATE("$srs_relay_log_name", "$table_relay_log_name") > 0] |
| 84 |
--let $assert_text= The file name for the repository and the show replica status match |
| 85 |
--source include/assert.inc |
| 86 |
|
| 87 |
--echo # |
| 88 |
--echo # 2. Stop replication and make the channel use GTID_ONLY=1 |
| 89 |
--echo # Start replication and add some values to the table. |
| 90 |
--echo # Check the repo shows the old values in relation to SHOW REPLICA STATUS |
| 91 |
|
| 92 |
--source include/stop_slave.inc |
| 93 |
|
| 94 |
CHANGE REPLICATION SOURCE TO GTID_ONLY = 1, REQUIRE_ROW_FORMAT=1; |
| 95 |
|
| 96 |
--let $table_relay_log_pos_orig = `SELECT Relay_log_pos FROM mysql.slave_relay_log_info` |
| 97 |
--let $table_relay_log_name_orig = `SELECT Relay_log_name FROM mysql.slave_relay_log_info` |
| 98 |
|
| 99 |
--source include/start_slave.inc |
| 100 |
|
| 101 |
--source include/rpl_connection_master.inc |
| 102 |
|
| 103 |
INSERT INTO t1 VALUES (2); |
| 104 |
|
| 105 |
--source include/sync_slave_sql_with_master.inc |
| 106 |
|
| 107 |
--let $srs_relay_log_pos = query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Relay_Log_Pos, 1) |
| 108 |
--let $table_relay_log_pos = `SELECT Relay_log_pos FROM mysql.slave_relay_log_info` |
| 109 |
|
| 110 |
--let $assert_cond= [ SELECT $srs_relay_log_pos != $table_relay_log_pos ] |
| 111 |
--let $assert_text= The repository position is not the one shown on show replica status |
| 112 |
--source include/assert.inc |
| 113 |
|
| 114 |
--let $assert_cond= [ SELECT $table_relay_log_pos = $table_relay_log_pos_orig ] |
| 115 |
--let $assert_text= The repository pos value is still the same |
| 116 |
--source include/assert.inc |
| 117 |
|
| 118 |
--let $table_relay_log_name = `SELECT Relay_log_name FROM mysql.slave_relay_log_info` |
| 119 |
--let $assert_cond= [ SELECT "$table_relay_log_name" = "$table_relay_log_name_orig" ] |
| 120 |
--let $assert_text= The repository name value is still the same |
| 121 |
--source include/assert.inc |
| 122 |
|
| 123 |
--echo # |
| 124 |
--echo # 3. Stop replication |
| 125 |
--echo # Check the repo still shows the old values in relation to SHOW REPLICA STATUS |
| 126 |
|
| 127 |
--source include/stop_slave.inc |
| 128 |
|
| 129 |
--let $srs_relay_log_pos = query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Relay_Log_Pos, 1) |
| 130 |
--let $table_relay_log_pos = `SELECT Relay_log_pos FROM mysql.slave_relay_log_info` |
| 131 |
|
| 132 |
--let $assert_cond= [ SELECT $srs_relay_log_pos != $table_relay_log_pos ] |
| 133 |
--let $assert_text= The repository position is not the one shown on show replica status |
| 134 |
--source include/assert.inc |
| 135 |
|
| 136 |
--let $assert_cond= [ SELECT $table_relay_log_pos = $table_relay_log_pos_orig ] |
| 137 |
--let $assert_text= The repository pos value is still the same |
| 138 |
--source include/assert.inc |
| 139 |
|
| 140 |
--let $table_relay_log_name = `SELECT Relay_log_name FROM mysql.slave_relay_log_info` |
| 141 |
--let $assert_cond= [ SELECT "$table_relay_log_name" = "$table_relay_log_name_orig" ] |
| 142 |
--let $assert_text= The repository name value is still the same |
| 143 |
--source include/assert.inc |
| 144 |
|
| 145 |
--echo # |
| 146 |
--echo # 4. Start replication again |
| 147 |
--echo # Check the repo still shows the old values in relation to SHOW REPLICA STATUS |
| 148 |
|
| 149 |
--source include/start_slave.inc |
| 150 |
|
| 151 |
--source include/rpl_connection_master.inc |
| 152 |
|
| 153 |
INSERT INTO t1 VALUES (3); |
| 154 |
|
| 155 |
--source include/sync_slave_sql_with_master.inc |
| 156 |
|
| 157 |
--let $srs_relay_log_pos = query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Relay_Log_Pos, 1) |
| 158 |
--let $table_relay_log_pos = `SELECT Relay_log_pos FROM mysql.slave_relay_log_info` |
| 159 |
|
| 160 |
--let $assert_cond= [ SELECT $srs_relay_log_pos != $table_relay_log_pos ] |
| 161 |
--let $assert_text= The repository position is not the one shown on show replica status |
| 162 |
--source include/assert.inc |
| 163 |
|
| 164 |
--let $srs_relay_log_name = query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Relay_Log_File, 1) |
| 165 |
# As the table string may contain path characters in it, we use the locate function |
| 166 |
--let $assert_cond= [ SELECT LOCATE("$srs_relay_log_name", "$table_relay_log_name") = 0 ] |
| 167 |
--let $assert_text= The repository file name is not the one shown on show replica status |
| 168 |
--source include/assert.inc |
| 169 |
|
| 170 |
--let $assert_cond= [ SELECT $table_relay_log_pos = $table_relay_log_pos_orig ] |
| 171 |
--let $assert_text= The repository pos value is still the same |
| 172 |
--source include/assert.inc |
| 173 |
|
| 174 |
--let $table_relay_log_name = `SELECT Relay_log_name FROM mysql.slave_relay_log_info` |
| 175 |
--let $assert_cond= [ SELECT "$table_relay_log_name" = "$table_relay_log_name_orig" ] |
| 176 |
--let $assert_text= The repository name value is still the same |
| 177 |
--source include/assert.inc |
| 178 |
|
| 179 |
--echo # |
| 180 |
--echo # 5. Kill the SQL thread |
| 181 |
--echo # Check the repo still shows the old values in relation to SHOW REPLICA STATUS |
| 182 |
|
| 183 |
--let $sql_applier_process_id=`SELECT PROCESSLIST_ID FROM performance_schema.threads WHERE NAME = 'thread/sql/replica_sql'` |
| 184 |
|
| 185 |
--disable_query_log |
| 186 |
--eval KILL $sql_applier_process_id |
| 187 |
--enable_query_log |
| 188 |
|
| 189 |
--let $slave_sql_errno= convert_error(ER_MTA_INCONSISTENT_DATA) |
| 190 |
--source include/wait_for_slave_sql_error.inc |
| 191 |
|
| 192 |
--let $srs_relay_log_pos = query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Relay_Log_Pos, 1) |
| 193 |
--let $table_relay_log_pos = `SELECT Relay_log_pos FROM mysql.slave_relay_log_info` |
| 194 |
|
| 195 |
--let $assert_cond= [ SELECT $srs_relay_log_pos != $table_relay_log_pos ] |
| 196 |
--let $assert_text= The repository position is not the one shown on show replica status |
| 197 |
--source include/assert.inc |
| 198 |
|
| 199 |
--let $srs_relay_log_name = query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Relay_Log_File, 1) |
| 200 |
|
| 201 |
# As the table string may contain path characters in it, we use the locate function |
| 202 |
--let $assert_cond= [ SELECT LOCATE("$srs_relay_log_name", "$table_relay_log_name") = 0 ] |
| 203 |
--let $assert_text= The repository file name is not the one shown on show replica status |
| 204 |
--source include/assert.inc |
| 205 |
|
| 206 |
--let $assert_cond= [ SELECT $table_relay_log_pos = $table_relay_log_pos_orig ] |
| 207 |
--let $assert_text= The repository pos value is still the same |
| 208 |
--source include/assert.inc |
| 209 |
|
| 210 |
--let $table_relay_log_name = `SELECT Relay_log_name FROM mysql.slave_relay_log_info` |
| 211 |
--let $assert_cond= [ SELECT "$table_relay_log_name" = "$table_relay_log_name_orig" ] |
| 212 |
--let $assert_text= The repository name value is still the same |
| 213 |
--source include/assert.inc |
| 214 |
|
| 215 |
--echo # |
| 216 |
--echo # 6. Change a replication connection setting with CHANGE REPLICATION SOURCE |
| 217 |
--echo # Check the repo now has the same value in relation to SHOW REPLICA STATUS |
| 218 |
|
| 219 |
--source include/stop_slave.inc |
| 220 |
|
| 221 |
CHANGE REPLICATION SOURCE TO SOURCE_CONNECT_RETRY = 10000; |
| 222 |
|
| 223 |
--let $srs_relay_log_pos = query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Relay_Log_Pos, 1) |
| 224 |
--let $table_relay_log_pos = `SELECT Relay_log_pos FROM mysql.slave_relay_log_info` |
| 225 |
--let $assert_cond= [ SELECT $srs_relay_log_pos = $table_relay_log_pos ] |
| 226 |
--let $assert_text= The repository has the lastest position |
| 227 |
--source include/assert.inc |
| 228 |
|
| 229 |
--let $srs_relay_log_name = query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Relay_Log_File, 1) |
| 230 |
--let $table_relay_log_name = `SELECT Relay_log_name FROM mysql.slave_relay_log_info` |
| 231 |
|
| 232 |
# As the table string may contain path characters in it, we use the locate function |
| 233 |
--let $assert_cond= [ SELECT LOCATE("$srs_relay_log_name", "$table_relay_log_name") > 0 ] |
| 234 |
--let $assert_text= The file name for the repository and the show replica status match |
| 235 |
--source include/assert.inc |
| 236 |
|
| 237 |
--echo # |
| 238 |
--echo # 7. Restart the replica server |
| 239 |
--echo # Check the repo still shows the old values |
| 240 |
|
| 241 |
--source include/start_slave.inc |
| 242 |
|
| 243 |
--source include/rpl_connection_master.inc |
| 244 |
|
| 245 |
INSERT INTO t1 VALUES (4); |
| 246 |
|
| 247 |
--source include/sync_slave_sql_with_master.inc |
| 248 |
|
| 249 |
--let $table_relay_log_pos_orig = `SELECT Relay_log_pos FROM mysql.slave_relay_log_info` |
| 250 |
--let $table_relay_log_name_orig = `SELECT Relay_log_name FROM mysql.slave_relay_log_info` |
| 251 |
|
| 252 |
--let $srs_relay_log_pos = query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Relay_Log_Pos, 1) |
| 253 |
--let $assert_cond= [ SELECT $srs_relay_log_pos != $table_relay_log_pos_orig ] |
| 254 |
--let $assert_text= The repository position is not the one shown on show replica status |
| 255 |
--source include/assert.inc |
| 256 |
|
| 257 |
--let $rpl_server_parameters= --skip_replica_start=FALSE |
| 258 |
--let $rpl_server_number = 2 |
| 259 |
--source include/rpl_restart_server.inc |
| 260 |
|
| 261 |
--let $table_relay_log_pos = `SELECT Relay_log_pos FROM mysql.slave_relay_log_info` |
| 262 |
--let $table_relay_log_name = `SELECT Relay_log_name FROM mysql.slave_relay_log_info` |
| 263 |
|
| 264 |
--let $assert_cond= [ SELECT $table_relay_log_pos = $table_relay_log_pos_orig ] |
| 265 |
--let $assert_text= The repository pos value is still the same |
| 266 |
--source include/assert.inc |
| 267 |
|
| 268 |
--let $assert_cond= [ SELECT "$table_relay_log_name" = "$table_relay_log_name_orig" ] |
| 269 |
--let $assert_text= The repository name value is still the same |
| 270 |
|
| 271 |
--echo # |
| 272 |
--echo # 8. Add some values and check the repo is again stale |
| 273 |
--echo # Execute a RESET REPLICA command |
| 274 |
--echo # Check the repo persisted the reset position |
| 275 |
|
| 276 |
--source include/rpl_connection_master.inc |
| 277 |
|
| 278 |
INSERT INTO t1 VALUES (5); |
| 279 |
|
| 280 |
--source include/sync_slave_sql_with_master.inc |
| 281 |
|
| 282 |
--let $srs_relay_log_pos = query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Relay_Log_Pos, 1) |
| 283 |
--let $table_relay_log_pos = `SELECT Relay_log_pos FROM mysql.slave_relay_log_info` |
| 284 |
|
| 285 |
--let $assert_cond= [ SELECT $srs_relay_log_pos != $table_relay_log_pos ] |
| 286 |
--let $assert_text= The repository position is not the one shown on show replica status |
| 287 |
--source include/assert.inc |
| 288 |
|
| 289 |
--source include/stop_slave.inc |
| 290 |
|
| 291 |
RESET REPLICA; |
| 292 |
|
| 293 |
--let $srs_relay_log_pos = query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Relay_Log_Pos, 1) |
| 294 |
--let $table_relay_log_pos = `SELECT Relay_log_pos FROM mysql.slave_relay_log_info` |
| 295 |
|
| 296 |
--query_vertical SELECT Relay_log_pos FROM mysql.slave_relay_log_info; |
| 297 |
--echo $srs_relay_log_pos |
| 298 |
--echo $table_relay_log_pos |
| 299 |
|
| 300 |
--let $assert_cond= [ SELECT $srs_relay_log_pos = 0 ] |
| 301 |
--let $assert_text= The position was reset as shown on show replica status |
| 302 |
--source include/assert.inc |
| 303 |
|
| 304 |
--let $assert_cond= [ SELECT "$table_relay_log_pos" = "" ] |
| 305 |
--let $assert_text= The repository reset the position |
| 306 |
--source include/assert.inc |
| 307 |
|
| 308 |
--echo # |
| 309 |
--echo # 9. Check RESET REPLICA ALL removes all the information |
| 310 |
|
| 311 |
--source include/start_slave.inc |
| 312 |
|
| 313 |
--source include/rpl_connection_master.inc |
| 314 |
|
| 315 |
INSERT INTO t1 VALUES (6); |
| 316 |
|
| 317 |
--source include/sync_slave_sql_with_master.inc |
| 318 |
|
| 319 |
--let $table_relay_log_pos = `SELECT Relay_log_pos FROM mysql.slave_relay_log_info` |
| 320 |
--let $assert_cond= [ SELECT $table_relay_log_pos = 4 ] |
| 321 |
--let $assert_text= The repository position was persisted when the channel was initialized after the reset |
| 322 |
--source include/assert.inc |
| 323 |
|
| 324 |
--source include/stop_slave.inc |
| 325 |
|
| 326 |
RESET REPLICA ALL; |
| 327 |
|
| 328 |
--let $assert_cond= COUNT(*) = 0 FROM mysql.slave_relay_log_info |
| 329 |
--let $assert_text= The repository info was deleted |
| 330 |
--source include/assert.inc |
| 331 |
|
| 332 |
--echo # |
| 333 |
--echo # 10. Cleanup |
| 334 |
|
| 335 |
--replace_result $replica_checkpoint_period_value CHECKPOINT_PERIOD |
| 336 |
--eval SET @@GLOBAL.replica_checkpoint_period=$replica_checkpoint_period_value; |
| 337 |
|
| 338 |
--replace_result $MASTER_MYPORT MASTER_PORT |
| 339 |
--eval CHANGE REPLICATION SOURCE TO SOURCE_HOST='127.0.0.1', SOURCE_PORT=$MASTER_MYPORT, SOURCE_USER='root' |
| 340 |
--source include/start_slave.inc |
| 341 |
|
| 342 |
call mtr.add_suppression("The replica coordinator and worker threads are stopped, possibly leaving data in inconsistent state"); |
| 343 |
|
| 344 |
--source include/rpl_connection_master.inc |
| 345 |
|
| 346 |
DROP TABLE t1; |
| 347 |
|
| 348 |
--source include/rpl_end.inc |
| 349 |
|