| 1 |
# ==== Purpose ==== |
| 2 |
# |
| 3 |
# This test validates that when positions are invalid they are reported as such |
| 4 |
# |
| 5 |
# ==== Requirements ==== |
| 6 |
# |
| 7 |
# R1. Verify that positions as shown as invalid in `SHOW REPLICA STATUS` |
| 8 |
# |
| 9 |
# ==== Implementation ==== |
| 10 |
# |
| 11 |
# 1. Setup: |
| 12 |
# Start the replica channel with GTID_ONLY=1 |
| 13 |
# Add some info in the source and replicate it |
| 14 |
# Restart the replica but don't start replication |
| 15 |
# 2 Assert all invalid positions in SHOW REPLICA STATUS are shown as such |
| 16 |
# 3 Start the replica IO thread. |
| 17 |
# Check receiver positions are now valid |
| 18 |
# 4 Start the replica SQL thread and replicate a transaction |
| 19 |
# Check applier positions in relation to the source are now valid |
| 20 |
# 5 Check the starting SQL thread message reports invalid positions |
| 21 |
# 6 Cleanup |
| 22 |
# |
| 23 |
# ==== References ==== |
| 24 |
# |
| 25 |
# WL#7491: GTID-based replication applier recovery and positioning |
| 26 |
# |
| 27 |
|
| 28 |
--source include/have_binlog_format_row.inc |
| 29 |
--let $rpl_skip_start_slave= 1 |
| 30 |
--source include/master-slave.inc |
| 31 |
|
| 32 |
--echo # |
| 33 |
--echo # 1. Setup: |
| 34 |
--echo # Start the replica channel with GTID_ONLY=1 |
| 35 |
--echo # Add some data in the source and replicate it |
| 36 |
--echo # Restart the replica but don't start replication |
| 37 |
|
| 38 |
--source include/rpl_connection_slave.inc |
| 39 |
|
| 40 |
# Reduce this to a minimum |
| 41 |
--let $replica_checkpoint_period_value = `SELECT @@global.replica_checkpoint_period` |
| 42 |
SET @@GLOBAL.replica_checkpoint_period= 1; |
| 43 |
|
| 44 |
CHANGE REPLICATION SOURCE TO REQUIRE_ROW_FORMAT = 1, GTID_ONLY = 1; |
| 45 |
|
| 46 |
--source include/start_slave.inc |
| 47 |
|
| 48 |
--let $assert_text= 'GTID_ONLY is enabled' |
| 49 |
--let $assert_cond= [SELECT GTID_ONLY FROM performance_schema.replication_connection_configuration, GTID_ONLY, 1] = 1 |
| 50 |
--source include/assert.inc |
| 51 |
|
| 52 |
--source include/rpl_connection_master.inc |
| 53 |
|
| 54 |
CREATE TABLE t(s INT); |
| 55 |
INSERT INTO t VALUES(1); |
| 56 |
|
| 57 |
--source include/sync_slave_sql_with_master.inc |
| 58 |
|
| 59 |
--let $source_log_file_orig=query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Source_Log_File, 1) |
| 60 |
--let $source_log_pos_orig=query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Read_Source_Log_Pos, 1) |
| 61 |
|
| 62 |
--let $rpl_server_number = 2 |
| 63 |
--let $rpl_server_parameters = --skip_slave_start |
| 64 |
--let $explicit_default_wait_counter = 15000 |
| 65 |
--source include/rpl_restart_server.inc |
| 66 |
|
| 67 |
--echo # |
| 68 |
--echo # 2 Assert all invalid positions in SHOW REPLICA STATUS are shown as such |
| 69 |
|
| 70 |
--let $source_log_file=query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Source_Log_File, 1) |
| 71 |
--let $assert_cond= [ SELECT "$source_log_file" = "INVALID" ] |
| 72 |
--let $assert_text= The source log file name is invalid |
| 73 |
--source include/assert.inc |
| 74 |
|
| 75 |
--let $source_log_pos=query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Read_Source_Log_Pos, 1) |
| 76 |
--let $assert_cond= [ SELECT "$source_log_pos" = "0" ] |
| 77 |
--let $assert_text= The source log file position is 0 |
| 78 |
--source include/assert.inc |
| 79 |
|
| 80 |
--let $applier_source_log_file=query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Relay_Source_Log_File, 1) |
| 81 |
--let $assert_cond= [ SELECT "$applier_source_log_file" = "INVALID" ] |
| 82 |
--let $assert_text= The source log file name in the applier is invalid |
| 83 |
--source include/assert.inc |
| 84 |
|
| 85 |
--let $applier_source_log_pos=query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Exec_Source_Log_Pos, 1) |
| 86 |
--let $assert_cond= [ SELECT "$applier_source_log_pos" = "0" ] |
| 87 |
--let $assert_text= The source log file position in the applier is 0 |
| 88 |
--source include/assert.inc |
| 89 |
|
| 90 |
--echo # |
| 91 |
--echo # 3 Start the replica IO thread. |
| 92 |
--echo # Check receiver positions are now valid |
| 93 |
|
| 94 |
--source include/start_slave_io.inc |
| 95 |
|
| 96 |
--let $show_statement= SHOW REPLICA STATUS FOR CHANNEL '' |
| 97 |
--let $field= Source_Log_File |
| 98 |
--let $condition= != 'INVALID' |
| 99 |
--source include/wait_show_condition.inc |
| 100 |
|
| 101 |
--let $source_log_file=query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Source_Log_File, 1) |
| 102 |
--let $assert_cond= [ SELECT "$source_log_file" = "$source_log_file_orig" ] |
| 103 |
--let $assert_text= The source log file name is back to the previous value |
| 104 |
--source include/assert.inc |
| 105 |
|
| 106 |
--let $source_log_pos=query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Read_Source_Log_Pos, 1) |
| 107 |
--let $assert_cond= [ SELECT "$source_log_pos" = "$source_log_pos_orig" ] |
| 108 |
--let $assert_text= The source log file is back to the previous position |
| 109 |
--source include/assert.inc |
| 110 |
|
| 111 |
--echo # |
| 112 |
--echo # 4 Start the replica SQL thread and replicate a transaction |
| 113 |
--echo # Check applier positions in relation to the source are now valid |
| 114 |
|
| 115 |
# Reduce this to a minimum again after the restart |
| 116 |
SET @@GLOBAL.replica_checkpoint_period= 1; |
| 117 |
|
| 118 |
--source include/start_slave_sql.inc |
| 119 |
|
| 120 |
--source include/rpl_connection_master.inc |
| 121 |
|
| 122 |
# In truth a simple rotate or already skipped transaction in the relay log |
| 123 |
# turns the positions valid again. |
| 124 |
INSERT INTO t VALUES(2); |
| 125 |
|
| 126 |
--source include/sync_slave_sql_with_master.inc |
| 127 |
|
| 128 |
--source include/rpl_connection_master.inc |
| 129 |
|
| 130 |
--let $log_file_on_source=query_get_value(SHOW MASTER STATUS, File, 1) |
| 131 |
--let $log_pos_on_source=query_get_value(SHOW MASTER STATUS, Position, 1) |
| 132 |
|
| 133 |
--source include/rpl_connection_slave.inc |
| 134 |
|
| 135 |
# Relay log is only updated on checkpoint points |
| 136 |
--let $show_statement= SHOW REPLICA STATUS FOR CHANNEL '' |
| 137 |
--let $field= Relay_Source_Log_File |
| 138 |
--let $condition= != 'INVALID' |
| 139 |
--source include/wait_show_condition.inc |
| 140 |
|
| 141 |
--let $applier_source_log_file=query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Relay_Source_Log_File, 1) |
| 142 |
--let $assert_cond= [ SELECT "$applier_source_log_file" = "$log_file_on_source" ] |
| 143 |
--let $assert_text= The source log file name for the applier is the one used on the source |
| 144 |
--source include/assert.inc |
| 145 |
|
| 146 |
--let $applier_source_log_pos=query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Exec_Source_Log_Pos, 1) |
| 147 |
--let $assert_cond= [ SELECT "$applier_source_log_pos" = "$log_pos_on_source" ] |
| 148 |
--let $assert_text= The source log file position in the applier is last applied on the source |
| 149 |
--source include/assert.inc |
| 150 |
|
| 151 |
--echo # |
| 152 |
--echo # 5 Check the starting SQL thread message reports invalid positions |
| 153 |
|
| 154 |
--let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.2.err |
| 155 |
--let $assert_select= Replica SQL thread for channel '' initialized, starting replication in log 'INVALID' at position 0, relay log * |
| 156 |
--let $assert_count= 1 |
| 157 |
--let $assert_text= The SQL thread start will report the information in relation to the source as invalid |
| 158 |
--source include/assert_grep.inc |
| 159 |
|
| 160 |
--echo # |
| 161 |
--echo # 6 Cleanup |
| 162 |
|
| 163 |
--replace_result $replica_checkpoint_period_value REPLICA_CHECKPOINT_PERIOD |
| 164 |
--eval SET @@GLOBAL.replica_checkpoint_period= $replica_checkpoint_period_value |
| 165 |
|
| 166 |
--source include/stop_slave.inc |
| 167 |
|
| 168 |
CHANGE REPLICATION SOURCE TO REQUIRE_ROW_FORMAT = 0, GTID_ONLY = 0; |
| 169 |
|
| 170 |
--source include/start_slave.inc |
| 171 |
|
| 172 |
--source include/rpl_connection_master.inc |
| 173 |
|
| 174 |
DROP TABLE t; |
| 175 |
|
| 176 |
--source include/rpl_end.inc |