| 1 |
# ==== Purpose ==== |
| 2 |
# |
| 3 |
# This test validates that repositories can be converted from one type to another. |
| 4 |
# The new repository will have up to date information |
| 5 |
# |
| 6 |
# ==== Requirements ==== |
| 7 |
# |
| 8 |
# R1. When repositories are converted the info written in them is the latest data in memory |
| 9 |
# R2. If a repository is converted while holding invalid position data, that data stays invalid |
| 10 |
# |
| 11 |
# ==== Implementation ==== |
| 12 |
# |
| 13 |
# 1. Setup: |
| 14 |
# Configure the replica channel with GTID_ONLY=1 |
| 15 |
# Restart the replica so it uses FILE repositories |
| 16 |
# 2. Add some data to the source |
| 17 |
# Logs are flushed to cause rotations in the replica making the applier repository point to a deleted file |
| 18 |
# Collect the info about the binlog file and position at the end |
| 19 |
# 3. Change the relay_log_info_repository type |
| 20 |
# Check the lasted information is set in the new repository |
| 21 |
# 4. Change the master_info_repository type |
| 22 |
# Check the lasted information is set in the new repository |
| 23 |
# 5. Start the replica, check that replication is working |
| 24 |
# 6. Restart the replica again so it uses FILE repositories. |
| 25 |
# Check that position related info is marked as invalid |
| 26 |
# 7. Convert the repositories |
| 27 |
# Check that position related info is still marked as invalid |
| 28 |
# 8. Start the replica, check that replication is working |
| 29 |
# 9. Cleanup |
| 30 |
# |
| 31 |
# ==== References ==== |
| 32 |
# |
| 33 |
# WL#7491: GTID-based replication applier recovery and positioning |
| 34 |
# |
| 35 |
|
| 36 |
--source include/have_binlog_format_row.inc |
| 37 |
--source include/have_slave_repository_type_table.inc |
| 38 |
|
| 39 |
# This test compares source log positions between source memory and replica |
| 40 |
# repositories. Ensure synchronization of the source log positions |
| 41 |
# between source and replica memory regardless of GTIDs. |
| 42 |
--let $ignore_gtids_on_sync= 1 |
| 43 |
|
| 44 |
--let $rpl_skip_start_slave= 1 |
| 45 |
--source include/master-slave.inc |
| 46 |
|
| 47 |
--echo # |
| 48 |
--echo # 1. Setup: |
| 49 |
--echo # Configure the replica channel with GTID_ONLY=1 |
| 50 |
--echo # Restart the replica so it uses FILE repositories |
| 51 |
|
| 52 |
--source include/rpl_connection_slave.inc |
| 53 |
|
| 54 |
CHANGE REPLICATION SOURCE TO REQUIRE_ROW_FORMAT = 1, GTID_ONLY = 1; |
| 55 |
|
| 56 |
--let $rpl_server_number= 2 |
| 57 |
--let $rpl_server_parameters= --relay_log_info_repository=FILE --master_info_repository=FILE --skip_slave_start=0 |
| 58 |
--source include/rpl_restart_server.inc |
| 59 |
|
| 60 |
# Make the collection of replica values more reliable |
| 61 |
--let $replica_checkpoint_period_value = `SELECT @@global.replica_checkpoint_period` |
| 62 |
SET @@GLOBAL.replica_checkpoint_period= 1; |
| 63 |
|
| 64 |
--echo # |
| 65 |
--echo # 2. Add some data to the source |
| 66 |
--echo # Logs are flushed to cause rotations in the replica making the applier repository point to a deleted file |
| 67 |
--echo # Collect the info about the binlog file and position at the end |
| 68 |
|
| 69 |
--source include/rpl_connection_master.inc |
| 70 |
|
| 71 |
CREATE TABLE t1(c1 INTEGER) ENGINE= Innodb; |
| 72 |
|
| 73 |
INSERT INTO t1 VALUES(1); |
| 74 |
|
| 75 |
FLUSH LOGS; |
| 76 |
|
| 77 |
INSERT INTO t1 VALUES(2); |
| 78 |
|
| 79 |
FLUSH LOGS; |
| 80 |
|
| 81 |
INSERT INTO t1 VALUES(3); |
| 82 |
|
| 83 |
FLUSH LOGS; |
| 84 |
|
| 85 |
--let $log_file_on_source=query_get_value(SHOW MASTER STATUS, File, 1) |
| 86 |
--let $log_pos_on_source=query_get_value(SHOW MASTER STATUS, Position, 1) |
| 87 |
|
| 88 |
--source include/sync_slave_sql_with_master.inc |
| 89 |
|
| 90 |
--echo # |
| 91 |
--echo # 3. Change the relay_log_info_repository type |
| 92 |
--echo # Check the lasted information is set in the new repository |
| 93 |
|
| 94 |
--source include/stop_slave.inc |
| 95 |
|
| 96 |
--let $applier_relaylog_pos=query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Relay_Log_Pos, 1) |
| 97 |
|
| 98 |
SET @@global.relay_log_info_repository="TABLE"; |
| 99 |
|
| 100 |
--let $repo_source_log_file=`SELECT Master_log_name FROM mysql.slave_relay_log_info` |
| 101 |
--let $assert_cond= [ SELECT "$repo_source_log_file" = "$log_file_on_source" ] |
| 102 |
--let $assert_text= The source log file name is up to date in the applier repo |
| 103 |
--source include/assert.inc |
| 104 |
|
| 105 |
--let $repo_source_log_pos=`SELECT Master_log_pos FROM mysql.slave_relay_log_info` |
| 106 |
--let $assert_cond= [ SELECT "$repo_source_log_pos" = "$log_pos_on_source" ] |
| 107 |
--let $assert_text= The source log position is up to date in the applier repo |
| 108 |
--source include/assert.inc |
| 109 |
|
| 110 |
--let $repo_relay_log_pos=`SELECT Relay_log_pos FROM mysql.slave_relay_log_info` |
| 111 |
--let $assert_cond= [ SELECT "$repo_relay_log_pos" = "$applier_relaylog_pos" ] |
| 112 |
--let $assert_text= The source log file name is up to date in the applier repo |
| 113 |
--source include/assert.inc |
| 114 |
|
| 115 |
--echo # |
| 116 |
--echo # 4. Change the master_info_repository type |
| 117 |
--echo # Check the lasted information is set in the new repository |
| 118 |
|
| 119 |
SET @@global.master_info_repository="TABLE"; |
| 120 |
|
| 121 |
--let $repo_source_log_file=`SELECT Master_log_name FROM mysql.slave_master_info` |
| 122 |
--let $assert_cond= [ SELECT "$repo_source_log_file" = "$log_file_on_source" ] |
| 123 |
--let $assert_text= The source log file name is up to date in the connection repo |
| 124 |
--source include/assert.inc |
| 125 |
|
| 126 |
--let $repo_source_log_pos=`SELECT Master_log_pos FROM mysql.slave_master_info` |
| 127 |
--let $assert_cond= [ SELECT "$repo_source_log_pos" = "$log_pos_on_source" ] |
| 128 |
--let $assert_text= The source log position is up to date in the connection repo |
| 129 |
--source include/assert.inc |
| 130 |
|
| 131 |
--echo # |
| 132 |
--echo # 5. Start the replica, check that replication is working |
| 133 |
|
| 134 |
--source include/rpl_connection_slave.inc |
| 135 |
|
| 136 |
--source include/start_slave.inc |
| 137 |
|
| 138 |
--source include/rpl_connection_master.inc |
| 139 |
|
| 140 |
INSERT INTO t1 VALUES(4); |
| 141 |
|
| 142 |
--source include/sync_slave_sql_with_master.inc |
| 143 |
|
| 144 |
--echo # |
| 145 |
--echo # 6. Restart the replica again so it uses FILE repositories. |
| 146 |
--echo # Check that position related info is marked as invalid |
| 147 |
|
| 148 |
--let $rpl_server_number= 2 |
| 149 |
--let $rpl_server_parameters= --relay_log_info_repository=FILE --master_info_repository=FILE --skip_slave_start=1 |
| 150 |
--source include/rpl_restart_server.inc |
| 151 |
|
| 152 |
--let $source_log_file=query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Source_Log_File, 1) |
| 153 |
--let $assert_cond= [ SELECT "$source_log_file" = "INVALID" ] |
| 154 |
--let $assert_text= The source log file name is invalid |
| 155 |
--source include/assert.inc |
| 156 |
|
| 157 |
--let $source_log_pos=query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Read_Source_Log_Pos, 1) |
| 158 |
--let $assert_cond= [ SELECT "$source_log_pos" = "0" ] |
| 159 |
--let $assert_text= The source log file position is 0 |
| 160 |
--source include/assert.inc |
| 161 |
|
| 162 |
--let $applier_source_log_file=query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Relay_Source_Log_File, 1) |
| 163 |
--let $assert_cond= [ SELECT "$applier_source_log_file" = "INVALID" ] |
| 164 |
--let $assert_text= The source log file name in the applier is invalid |
| 165 |
--source include/assert.inc |
| 166 |
|
| 167 |
--let $applier_source_log_pos=query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Exec_Source_Log_Pos, 1) |
| 168 |
--let $assert_cond= [ SELECT "$applier_source_log_pos" = "0" ] |
| 169 |
--let $assert_text= The source log file position in the applier is 0 |
| 170 |
--source include/assert.inc |
| 171 |
|
| 172 |
--echo # |
| 173 |
--echo # 7. Convert the repositories |
| 174 |
--echo # Check that position related info is still marked as invalid |
| 175 |
|
| 176 |
SET @@global.relay_log_info_repository="TABLE"; |
| 177 |
SET @@global.master_info_repository="TABLE"; |
| 178 |
|
| 179 |
--let $source_log_file=query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Source_Log_File, 1) |
| 180 |
--let $assert_cond= [ SELECT "$source_log_file" = "INVALID" ] |
| 181 |
--let $assert_text= The source log file name is invalid |
| 182 |
--source include/assert.inc |
| 183 |
|
| 184 |
--let $source_log_pos=query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Read_Source_Log_Pos, 1) |
| 185 |
--let $assert_cond= [ SELECT "$source_log_pos" = "0" ] |
| 186 |
--let $assert_text= The source log file position is 0 |
| 187 |
--source include/assert.inc |
| 188 |
|
| 189 |
--let $applier_source_log_file=query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Relay_Source_Log_File, 1) |
| 190 |
--let $assert_cond= [ SELECT "$applier_source_log_file" = "INVALID" ] |
| 191 |
--let $assert_text= The source log file name in the applier is invalid |
| 192 |
--source include/assert.inc |
| 193 |
|
| 194 |
--let $applier_source_log_pos=query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Exec_Source_Log_Pos, 1) |
| 195 |
--let $assert_cond= [ SELECT "$applier_source_log_pos" = "0" ] |
| 196 |
--let $assert_text= The source log file position in the applier is 0 |
| 197 |
--source include/assert.inc |
| 198 |
|
| 199 |
--echo # |
| 200 |
--echo # 8. Start the replica, check that replication is working |
| 201 |
|
| 202 |
--source include/start_slave.inc |
| 203 |
|
| 204 |
--source include/rpl_connection_master.inc |
| 205 |
|
| 206 |
INSERT INTO t1 VALUES(5); |
| 207 |
|
| 208 |
--source include/sync_slave_sql_with_master.inc |
| 209 |
|
| 210 |
--echo # |
| 211 |
--echo # 9. Cleanup |
| 212 |
|
| 213 |
--source include/stop_slave.inc |
| 214 |
|
| 215 |
CHANGE REPLICATION SOURCE TO REQUIRE_ROW_FORMAT = 0, GTID_ONLY = 0; |
| 216 |
|
| 217 |
--replace_result $replica_checkpoint_period_value REPLICA_CHECKPOINT_PERIOD |
| 218 |
--eval SET @@GLOBAL.replica_checkpoint_period= $replica_checkpoint_period_value |
| 219 |
|
| 220 |
--source include/start_slave.inc |
| 221 |
|
| 222 |
--source include/rpl_connection_master.inc |
| 223 |
|
| 224 |
DROP TABLE t1; |
| 225 |
|
| 226 |
--source include/rpl_end.inc |