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
|
# ==== Purpose ====
#
# This test validates that repositories can be converted from one type to another.
# The new repository will have up to date information
#
# ==== Requirements ====
#
# R1. When repositories are converted the info written in them is the latest data in memory
# R2. If a repository is converted while holding invalid position data, that data stays invalid
#
# ==== Implementation ====
#
# 1. Setup:
# Configure the replica channel with GTID_ONLY=1
# Restart the replica so it uses FILE repositories
# 2. Add some data to the source
# Logs are flushed to cause rotations in the replica making the applier repository point to a deleted file
# Collect the info about the binlog file and position at the end
# 3. Change the relay_log_info_repository type
# Check the lasted information is set in the new repository
# 4. Change the master_info_repository type
# Check the lasted information is set in the new repository
# 5. Start the replica, check that replication is working
# 6. Restart the replica again so it uses FILE repositories.
# Check that position related info is marked as invalid
# 7. Convert the repositories
# Check that position related info is still marked as invalid
# 8. Start the replica, check that replication is working
# 9. Cleanup
#
# ==== References ====
#
# WL#7491: GTID-based replication applier recovery and positioning
#
--source include/have_binlog_format_row.inc
--source include/have_slave_repository_type_table.inc
# This test compares source log positions between source memory and replica
# repositories. Ensure synchronization of the source log positions
# between source and replica memory regardless of GTIDs.
--let $ignore_gtids_on_sync= 1
--let $rpl_skip_start_slave= 1
--source include/master-slave.inc
--echo #
--echo # 1. Setup:
--echo # Configure the replica channel with GTID_ONLY=1
--echo # Restart the replica so it uses FILE repositories
--source include/rpl_connection_slave.inc
CHANGE REPLICATION SOURCE TO REQUIRE_ROW_FORMAT = 1, GTID_ONLY = 1;
--let $rpl_server_number= 2
--let $rpl_server_parameters= --relay_log_info_repository=FILE --master_info_repository=FILE --skip_slave_start=0
--source include/rpl_restart_server.inc
# Make the collection of replica values more reliable
--let $replica_checkpoint_period_value = `SELECT @@global.replica_checkpoint_period`
SET @@GLOBAL.replica_checkpoint_period= 1;
--echo #
--echo # 2. Add some data to the source
--echo # Logs are flushed to cause rotations in the replica making the applier repository point to a deleted file
--echo # Collect the info about the binlog file and position at the end
--source include/rpl_connection_master.inc
CREATE TABLE t1(c1 INTEGER) ENGINE= Innodb;
INSERT INTO t1 VALUES(1);
FLUSH LOGS;
INSERT INTO t1 VALUES(2);
FLUSH LOGS;
INSERT INTO t1 VALUES(3);
FLUSH LOGS;
--let $log_file_on_source=query_get_value(SHOW MASTER STATUS, File, 1)
--let $log_pos_on_source=query_get_value(SHOW MASTER STATUS, Position, 1)
--source include/sync_slave_sql_with_master.inc
--echo #
--echo # 3. Change the relay_log_info_repository type
--echo # Check the lasted information is set in the new repository
--source include/stop_slave.inc
--let $applier_relaylog_pos=query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Relay_Log_Pos, 1)
SET @@global.relay_log_info_repository="TABLE";
--let $repo_source_log_file=`SELECT Master_log_name FROM mysql.slave_relay_log_info`
--let $assert_cond= [ SELECT "$repo_source_log_file" = "$log_file_on_source" ]
--let $assert_text= The source log file name is up to date in the applier repo
--source include/assert.inc
--let $repo_source_log_pos=`SELECT Master_log_pos FROM mysql.slave_relay_log_info`
--let $assert_cond= [ SELECT "$repo_source_log_pos" = "$log_pos_on_source" ]
--let $assert_text= The source log position is up to date in the applier repo
--source include/assert.inc
--let $repo_relay_log_pos=`SELECT Relay_log_pos FROM mysql.slave_relay_log_info`
--let $assert_cond= [ SELECT "$repo_relay_log_pos" = "$applier_relaylog_pos" ]
--let $assert_text= The source log file name is up to date in the applier repo
--source include/assert.inc
--echo #
--echo # 4. Change the master_info_repository type
--echo # Check the lasted information is set in the new repository
SET @@global.master_info_repository="TABLE";
--let $repo_source_log_file=`SELECT Master_log_name FROM mysql.slave_master_info`
--let $assert_cond= [ SELECT "$repo_source_log_file" = "$log_file_on_source" ]
--let $assert_text= The source log file name is up to date in the connection repo
--source include/assert.inc
--let $repo_source_log_pos=`SELECT Master_log_pos FROM mysql.slave_master_info`
--let $assert_cond= [ SELECT "$repo_source_log_pos" = "$log_pos_on_source" ]
--let $assert_text= The source log position is up to date in the connection repo
--source include/assert.inc
--echo #
--echo # 5. Start the replica, check that replication is working
--source include/rpl_connection_slave.inc
--source include/start_slave.inc
--source include/rpl_connection_master.inc
INSERT INTO t1 VALUES(4);
--source include/sync_slave_sql_with_master.inc
--echo #
--echo # 6. Restart the replica again so it uses FILE repositories.
--echo # Check that position related info is marked as invalid
--let $rpl_server_number= 2
--let $rpl_server_parameters= --relay_log_info_repository=FILE --master_info_repository=FILE --skip_slave_start=1
--source include/rpl_restart_server.inc
--let $source_log_file=query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Source_Log_File, 1)
--let $assert_cond= [ SELECT "$source_log_file" = "INVALID" ]
--let $assert_text= The source log file name is invalid
--source include/assert.inc
--let $source_log_pos=query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Read_Source_Log_Pos, 1)
--let $assert_cond= [ SELECT "$source_log_pos" = "0" ]
--let $assert_text= The source log file position is 0
--source include/assert.inc
--let $applier_source_log_file=query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Relay_Source_Log_File, 1)
--let $assert_cond= [ SELECT "$applier_source_log_file" = "INVALID" ]
--let $assert_text= The source log file name in the applier is invalid
--source include/assert.inc
--let $applier_source_log_pos=query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Exec_Source_Log_Pos, 1)
--let $assert_cond= [ SELECT "$applier_source_log_pos" = "0" ]
--let $assert_text= The source log file position in the applier is 0
--source include/assert.inc
--echo #
--echo # 7. Convert the repositories
--echo # Check that position related info is still marked as invalid
SET @@global.relay_log_info_repository="TABLE";
SET @@global.master_info_repository="TABLE";
--let $source_log_file=query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Source_Log_File, 1)
--let $assert_cond= [ SELECT "$source_log_file" = "INVALID" ]
--let $assert_text= The source log file name is invalid
--source include/assert.inc
--let $source_log_pos=query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Read_Source_Log_Pos, 1)
--let $assert_cond= [ SELECT "$source_log_pos" = "0" ]
--let $assert_text= The source log file position is 0
--source include/assert.inc
--let $applier_source_log_file=query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Relay_Source_Log_File, 1)
--let $assert_cond= [ SELECT "$applier_source_log_file" = "INVALID" ]
--let $assert_text= The source log file name in the applier is invalid
--source include/assert.inc
--let $applier_source_log_pos=query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Exec_Source_Log_Pos, 1)
--let $assert_cond= [ SELECT "$applier_source_log_pos" = "0" ]
--let $assert_text= The source log file position in the applier is 0
--source include/assert.inc
--echo #
--echo # 8. Start the replica, check that replication is working
--source include/start_slave.inc
--source include/rpl_connection_master.inc
INSERT INTO t1 VALUES(5);
--source include/sync_slave_sql_with_master.inc
--echo #
--echo # 9. Cleanup
--source include/stop_slave.inc
CHANGE REPLICATION SOURCE TO REQUIRE_ROW_FORMAT = 0, GTID_ONLY = 0;
--replace_result $replica_checkpoint_period_value REPLICA_CHECKPOINT_PERIOD
--eval SET @@GLOBAL.replica_checkpoint_period= $replica_checkpoint_period_value
--source include/start_slave.inc
--source include/rpl_connection_master.inc
DROP TABLE t1;
--source include/rpl_end.inc
|