| 1 |
# ==== Purpose ==== |
| 2 |
# |
| 3 |
# This test validates that no info is persisted in the connection metadata repository |
| 4 |
# |
| 5 |
# ==== Requirements ==== |
| 6 |
# |
| 7 |
# For the connection metadata repository: |
| 8 |
# R1. When CHANGE REPLICATION SOURCE is executed the repository fields are persisted |
| 9 |
# R2. Position information is updated when an event is queued but 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 receiver 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 IO 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 now has 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/skip_config_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 # Set the value of sync_source_info to 1 so the repo is always synced |
| 58 |
--echo # Check the repo shows the same value as SHOW REPLICA STATUS |
| 59 |
|
| 60 |
--source include/rpl_connection_slave.inc |
| 61 |
|
| 62 |
# Make the info be synced at each event |
| 63 |
--let $sync_source_info_val = `SELECT @@GLOBAL.sync_source_info;` |
| 64 |
SET @@GLOBAL.sync_source_info=1; |
| 65 |
|
| 66 |
--source include/rpl_connection_master.inc |
| 67 |
|
| 68 |
CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY); |
| 69 |
|
| 70 |
INSERT INTO t1 VALUES (1); |
| 71 |
|
| 72 |
--source include/sync_slave_sql_with_master.inc |
| 73 |
|
| 74 |
--let $srs_source_log_pos = query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Read_Source_Log_Pos, 1) |
| 75 |
--let $table_source_log_pos = `SELECT Master_log_pos FROM mysql.slave_master_info` |
| 76 |
|
| 77 |
--let $assert_cond= [ SELECT $srs_source_log_pos = $table_source_log_pos ] |
| 78 |
--let $assert_text= The file position for the repository and the show replica status match |
| 79 |
--source include/assert.inc |
| 80 |
|
| 81 |
--let $srs_source_log_file = query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Source_Log_File, 1) |
| 82 |
--let $table_source_log_file = `SELECT Master_log_name FROM mysql.slave_master_info` |
| 83 |
|
| 84 |
--let $assert_cond= [ SELECT "$srs_source_log_file" = "$table_source_log_file" ] |
| 85 |
--let $assert_text= The file name for the repository and the show replica status match |
| 86 |
--source include/assert.inc |
| 87 |
|
| 88 |
--echo # |
| 89 |
--echo # 2. Stop replication and make the channel use GTID_ONLY=1 |
| 90 |
--echo # Start replication and add some values to the table. |
| 91 |
--echo # Check the repo shows the old values in relation to SHOW REPLICA STATUS |
| 92 |
|
| 93 |
--source include/stop_slave.inc |
| 94 |
|
| 95 |
CHANGE REPLICATION SOURCE TO GTID_ONLY = 1, REQUIRE_ROW_FORMAT=1; |
| 96 |
|
| 97 |
--let $table_source_log_pos_orig = `SELECT Master_log_pos FROM mysql.slave_master_info` |
| 98 |
--let $table_source_log_file_orig = `SELECT Master_log_name FROM mysql.slave_master_info` |
| 99 |
|
| 100 |
--source include/start_slave.inc |
| 101 |
|
| 102 |
--source include/rpl_connection_master.inc |
| 103 |
|
| 104 |
INSERT INTO t1 VALUES (2); |
| 105 |
|
| 106 |
--source include/sync_slave_sql_with_master.inc |
| 107 |
|
| 108 |
--let $srs_source_log_pos=query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Read_Source_Log_Pos, 1) |
| 109 |
--let $table_source_log_pos = `SELECT Master_log_pos FROM mysql.slave_master_info` |
| 110 |
--let $assert_cond= [ SELECT $srs_source_log_pos != $table_source_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_source_log_pos = $table_source_log_pos_orig ] |
| 115 |
--let $assert_text= The repository pos value is still the same |
| 116 |
--source include/assert.inc |
| 117 |
|
| 118 |
--let $table_source_log_file = `SELECT Master_log_name FROM mysql.slave_master_info` |
| 119 |
--let $assert_cond= [ SELECT "$table_source_log_file" = "$table_source_log_file_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_source_log_pos=query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Read_Source_Log_Pos, 1) |
| 130 |
--let $table_source_log_pos = `SELECT Master_log_pos FROM mysql.slave_master_info` |
| 131 |
--let $assert_cond= [ SELECT $srs_source_log_pos != $table_source_log_pos ] |
| 132 |
--let $assert_text= The repository position is not the one shown on show replica status |
| 133 |
--source include/assert.inc |
| 134 |
|
| 135 |
--let $assert_cond= [ SELECT $table_source_log_pos = $table_source_log_pos_orig ] |
| 136 |
--let $assert_text= The repository pos value is still the same |
| 137 |
--source include/assert.inc |
| 138 |
|
| 139 |
--let $table_source_log_file = `SELECT Master_log_name FROM mysql.slave_master_info` |
| 140 |
--let $assert_cond= [ SELECT "$table_source_log_file" = "$table_source_log_file_orig" ] |
| 141 |
--let $assert_text= The repository name value is still the same |
| 142 |
--source include/assert.inc |
| 143 |
|
| 144 |
--echo # |
| 145 |
--echo # 4. Start replication again |
| 146 |
--echo # Check the repo still shows the old values in relation to SHOW REPLICA STATUS |
| 147 |
|
| 148 |
--source include/start_slave.inc |
| 149 |
|
| 150 |
--source include/rpl_connection_master.inc |
| 151 |
|
| 152 |
FLUSH LOGS; |
| 153 |
|
| 154 |
INSERT INTO t1 VALUES (3); |
| 155 |
|
| 156 |
--source include/sync_slave_sql_with_master.inc |
| 157 |
|
| 158 |
--let $srs_source_log_pos=query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Read_Source_Log_Pos, 1) |
| 159 |
--let $table_source_log_pos = `SELECT Master_log_pos FROM mysql.slave_master_info` |
| 160 |
--let $assert_cond= [ SELECT $srs_source_log_pos != $table_source_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_source_log_file = query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Source_Log_File, 1) |
| 165 |
--let $table_source_log_file = `SELECT Master_log_name FROM mysql.slave_master_info` |
| 166 |
--let $assert_cond= [ SELECT "$srs_source_log_file" != "$table_source_log_file" ] |
| 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_source_log_pos = $table_source_log_pos_orig ] |
| 171 |
--let $assert_text= The repository pos value is still the same |
| 172 |
--source include/assert.inc |
| 173 |
|
| 174 |
--let $assert_cond= [ SELECT "$table_source_log_file" = "$table_source_log_file_orig" ] |
| 175 |
--let $assert_text= The repository name value is still the same |
| 176 |
--source include/assert.inc |
| 177 |
|
| 178 |
--echo # |
| 179 |
--echo # 5. Kill the IO thread |
| 180 |
--echo # Check the repo still shows the old values in relation to SHOW REPLICA STATUS |
| 181 |
|
| 182 |
let $receiver_process_id= `SELECT Id FROM information_schema.processlist WHERE State= "Waiting for source to send event"`; |
| 183 |
|
| 184 |
--disable_query_log |
| 185 |
--eval KILL $receiver_process_id |
| 186 |
--enable_query_log |
| 187 |
|
| 188 |
--source include/wait_for_slave_io_to_stop.inc |
| 189 |
|
| 190 |
--let $srs_source_log_pos=query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Read_Source_Log_Pos, 1) |
| 191 |
--let $table_source_log_pos = `SELECT Master_log_pos FROM mysql.slave_master_info` |
| 192 |
--let $assert_cond= [ SELECT $srs_source_log_pos != $table_source_log_pos ] |
| 193 |
--let $assert_text= The repository position is not the one shown on show replica status |
| 194 |
--source include/assert.inc |
| 195 |
|
| 196 |
--let $srs_source_log_file = query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Source_Log_File, 1) |
| 197 |
--let $table_source_log_file = `SELECT Master_log_name FROM mysql.slave_master_info` |
| 198 |
--let $assert_cond= [ SELECT "$srs_source_log_file" != "$table_source_log_file" ] |
| 199 |
--let $assert_text= The repository file name is not the one shown on show replica status |
| 200 |
--source include/assert.inc |
| 201 |
|
| 202 |
--let $assert_cond= [ SELECT $table_source_log_pos = $table_source_log_pos_orig ] |
| 203 |
--let $assert_text= The repository pos value is still the same |
| 204 |
--source include/assert.inc |
| 205 |
|
| 206 |
--let $assert_cond= [ SELECT "$table_source_log_file" = "$table_source_log_file_orig" ] |
| 207 |
--let $assert_text= The repository name value is still the same |
| 208 |
--source include/assert.inc |
| 209 |
|
| 210 |
--echo # |
| 211 |
--echo # 6. Change a replication connection setting with CHANGE REPLICATION SOURCE |
| 212 |
--echo # Check the repo now has the same value in relation to SHOW REPLICA STATUS |
| 213 |
|
| 214 |
--source include/stop_slave.inc |
| 215 |
|
| 216 |
CHANGE REPLICATION SOURCE TO SOURCE_CONNECT_RETRY = 10000; |
| 217 |
|
| 218 |
--let $srs_source_log_pos=query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Read_Source_Log_Pos, 1) |
| 219 |
--let $table_source_log_pos = `SELECT Master_log_pos FROM mysql.slave_master_info` |
| 220 |
--let $assert_cond= [ SELECT $srs_source_log_pos = $table_source_log_pos ] |
| 221 |
--let $assert_text= The repository now has the lastest position |
| 222 |
--source include/assert.inc |
| 223 |
|
| 224 |
--let $srs_source_log_file = query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Source_Log_File, 1) |
| 225 |
--let $table_source_log_file = `SELECT Master_log_name FROM mysql.slave_master_info` |
| 226 |
--let $assert_cond= [ SELECT "$srs_source_log_file" = "$table_source_log_file" ] |
| 227 |
--let $assert_text= The file name for the repository and the show replica status match |
| 228 |
--source include/assert.inc |
| 229 |
|
| 230 |
--echo # |
| 231 |
--echo # 7. Restart the replica server |
| 232 |
--echo # Check the repo still shows the old values |
| 233 |
|
| 234 |
--source include/start_slave.inc |
| 235 |
|
| 236 |
--source include/rpl_connection_master.inc |
| 237 |
|
| 238 |
INSERT INTO t1 VALUES (4); |
| 239 |
|
| 240 |
--source include/sync_slave_sql_with_master.inc |
| 241 |
|
| 242 |
--let $table_source_log_pos_orig = `SELECT Master_log_pos FROM mysql.slave_master_info` |
| 243 |
--let $table_source_log_file_orig = `SELECT Master_log_name FROM mysql.slave_master_info` |
| 244 |
|
| 245 |
--let $srs_source_log_pos=query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Read_Source_Log_Pos, 1) |
| 246 |
--let $assert_cond= [ SELECT $srs_source_log_pos != $table_source_log_pos_orig ] |
| 247 |
--let $assert_text= The repository position is not the one shown on show replica status |
| 248 |
--source include/assert.inc |
| 249 |
|
| 250 |
--let $rpl_server_parameters= --skip_replica_start=FALSE |
| 251 |
--let $rpl_server_number = 2 |
| 252 |
--source include/rpl_restart_server.inc |
| 253 |
|
| 254 |
--let $table_source_log_pos = `SELECT Master_log_pos FROM mysql.slave_master_info` |
| 255 |
--let $table_source_log_file = `SELECT Master_log_name FROM mysql.slave_master_info` |
| 256 |
|
| 257 |
--let $assert_cond= [ SELECT $table_source_log_pos_orig = $table_source_log_pos ] |
| 258 |
--let $assert_text= The repository pos value is still the same |
| 259 |
--source include/assert.inc |
| 260 |
|
| 261 |
--let $assert_cond= [ SELECT "$table_source_log_file" = "$table_source_log_file_orig" ] |
| 262 |
--let $assert_text= The repository name value is still the same |
| 263 |
|
| 264 |
--echo # |
| 265 |
--echo # 8. Add some values and check the repo is again stale |
| 266 |
--echo # Execute a RESET REPLICA command |
| 267 |
--echo # Check the repo persisted the reset position |
| 268 |
|
| 269 |
--source include/rpl_connection_master.inc |
| 270 |
|
| 271 |
INSERT INTO t1 VALUES (5); |
| 272 |
|
| 273 |
--source include/sync_slave_sql_with_master.inc |
| 274 |
|
| 275 |
--let $srs_source_log_pos=query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Read_Source_Log_Pos, 1) |
| 276 |
--let $table_source_log_pos = `SELECT Master_log_pos FROM mysql.slave_master_info` |
| 277 |
--let $assert_cond= [ SELECT $srs_source_log_pos != $table_source_log_pos ] |
| 278 |
--let $assert_text= The repository has not persisted |
| 279 |
--source include/assert.inc |
| 280 |
|
| 281 |
--source include/stop_slave.inc |
| 282 |
|
| 283 |
RESET REPLICA; |
| 284 |
|
| 285 |
--let $srs_source_log_pos=query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Read_Source_Log_Pos, 1) |
| 286 |
--let $table_source_log_pos = `SELECT Master_log_pos FROM mysql.slave_master_info` |
| 287 |
--let $assert_cond= [ SELECT $srs_source_log_pos = $table_source_log_pos ] |
| 288 |
--let $assert_text= The repository has the reset position |
| 289 |
--source include/assert.inc |
| 290 |
|
| 291 |
--let $assert_cond= [ SELECT $table_source_log_pos = 4 ] |
| 292 |
--let $assert_text= The repository has the reset position |
| 293 |
--source include/assert.inc |
| 294 |
|
| 295 |
--echo # |
| 296 |
--echo # 9. Check RESET REPLICA ALL removes all the information |
| 297 |
|
| 298 |
--source include/start_slave.inc |
| 299 |
|
| 300 |
--source include/rpl_connection_master.inc |
| 301 |
|
| 302 |
INSERT INTO t1 VALUES (6); |
| 303 |
|
| 304 |
--source include/sync_slave_sql_with_master.inc |
| 305 |
|
| 306 |
--let $table_source_log_pos = `SELECT Master_log_pos FROM mysql.slave_master_info` |
| 307 |
--let $assert_cond= [ SELECT $table_source_log_pos = 4 ] |
| 308 |
--let $assert_text= The repository still has the reset position |
| 309 |
--source include/assert.inc |
| 310 |
|
| 311 |
--source include/stop_slave.inc |
| 312 |
|
| 313 |
RESET REPLICA ALL; |
| 314 |
|
| 315 |
--let $assert_cond= COUNT(*) = 0 FROM mysql.slave_master_info |
| 316 |
--let $assert_text= The repository info was deleted |
| 317 |
--source include/assert.inc |
| 318 |
|
| 319 |
--echo # |
| 320 |
--echo # 10. Cleanup |
| 321 |
|
| 322 |
--replace_result $MASTER_MYPORT MASTER_PORT |
| 323 |
--eval CHANGE REPLICATION SOURCE TO SOURCE_HOST='127.0.0.1', SOURCE_PORT=$MASTER_MYPORT, SOURCE_USER='root' |
| 324 |
--source include/start_slave.inc |
| 325 |
|
| 326 |
--replace_result $sync_source_info_val SYNC_SOURCE_VAL |
| 327 |
--eval SET @@GLOBAL.sync_source_info=$sync_source_info_val |
| 328 |
|
| 329 |
--source include/rpl_connection_master.inc |
| 330 |
|
| 331 |
DROP TABLE t1; |
| 332 |
|
| 333 |
--source include/rpl_end.inc |