| 1 |
# ==== Purpose ==== |
| 2 |
# |
| 3 |
# This test validates SOURCE_POS_WAIT blocks when positions are invalid. |
| 4 |
# Unblocks when positions become valid again |
| 5 |
# |
| 6 |
# ==== Requirements ==== |
| 7 |
# |
| 8 |
# R1. Verify that SOURCE_POS_WAIT blocks when applier positions are invalid |
| 9 |
# and unblocks when positions are again valid |
| 10 |
# |
| 11 |
# ==== Implementation ==== |
| 12 |
# |
| 13 |
# 1. Setup: |
| 14 |
# Start the replica channel with GTID_ONLY=1 |
| 15 |
# Add some info in the source and replicate it |
| 16 |
# Record the source positions to wait later on |
| 17 |
# 2. Start replication |
| 18 |
# Check SOURCE_POS_WAIT does not time out when giving it a valid positioning info |
| 19 |
# 3. Restart the server so positions become invalid |
| 20 |
# Use relay log recovery so the new relay log contains no source info when the applier starts |
| 21 |
# 4. Test that the command times out cause positions are invalid |
| 22 |
# 5. Execute a wait with a large timeout |
| 23 |
# Turn applier positions valid again |
| 24 |
# Check the function does not time out when positions become valid |
| 25 |
# 6. SOURCE_POS_WAIT does not timeout when invoked with valid positioning info |
| 26 |
# 7. Cleanup |
| 27 |
# |
| 28 |
# ==== References ==== |
| 29 |
# |
| 30 |
# WL#7491: GTID-based replication applier recovery and positioning |
| 31 |
# |
| 32 |
|
| 33 |
--source include/have_binlog_format_row.inc |
| 34 |
--let $rpl_skip_start_slave= 1 |
| 35 |
--source include/master-slave.inc |
| 36 |
|
| 37 |
--echo # |
| 38 |
--echo # 1. Setup: |
| 39 |
--echo # Start the replica channel with GTID_ONLY=1 |
| 40 |
--echo # Add some info in the source and replicate it |
| 41 |
--echo # Record the source positions to wait later on |
| 42 |
|
| 43 |
--source include/rpl_connection_slave.inc |
| 44 |
|
| 45 |
CHANGE REPLICATION SOURCE TO REQUIRE_ROW_FORMAT = 1, GTID_ONLY = 1; |
| 46 |
|
| 47 |
--source include/rpl_connection_master.inc |
| 48 |
|
| 49 |
CREATE TABLE t(s INT); |
| 50 |
|
| 51 |
INSERT INTO t VALUES(1); |
| 52 |
|
| 53 |
--let $log_file_on_source=query_get_value(SHOW MASTER STATUS, File, 1) |
| 54 |
--let $log_pos_on_source=query_get_value(SHOW MASTER STATUS, Position, 1) |
| 55 |
|
| 56 |
INSERT INTO t VALUES(2); |
| 57 |
|
| 58 |
--echo # |
| 59 |
--echo # 2. Start replication |
| 60 |
--echo # Check SOURCE_POS_WAIT does not time out when giving it a valid positioning info |
| 61 |
|
| 62 |
--source include/rpl_connection_slave.inc |
| 63 |
|
| 64 |
--source include/start_slave.inc |
| 65 |
|
| 66 |
--source include/rpl_connection_master.inc |
| 67 |
|
| 68 |
--source include/sync_slave_sql_with_master.inc |
| 69 |
|
| 70 |
--let $source_post_wait_res = `SELECT SOURCE_POS_WAIT('$log_file_on_source', $log_pos_on_source, 30)` |
| 71 |
|
| 72 |
--let $assert_cond= [ SELECT "$source_post_wait_res" != "-1" ] |
| 73 |
--let $assert_text= The function did not time out |
| 74 |
--source include/assert.inc |
| 75 |
|
| 76 |
--echo # |
| 77 |
--echo # 3. Restart the server so positions become invalid |
| 78 |
--echo # Use relay log recovery so the new relay log contains no source info when the applier starts |
| 79 |
|
| 80 |
--let $rpl_server_number = 2 |
| 81 |
--let $rpl_server_parameters = --skip_slave_start=1 --relay-log-recovery=1 |
| 82 |
--let $explicit_default_wait_counter = 15000 |
| 83 |
--source include/rpl_restart_server.inc |
| 84 |
|
| 85 |
--source include/start_slave_sql.inc |
| 86 |
|
| 87 |
--let $applier_source_log_file=query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Relay_Source_Log_File, 1) |
| 88 |
--let $assert_cond= [ SELECT "$applier_source_log_file" = "INVALID" ] |
| 89 |
--let $assert_text= The source log file name in the applier is invalid |
| 90 |
--source include/assert.inc |
| 91 |
|
| 92 |
--let $applier_source_log_pos=query_get_value(SHOW REPLICA STATUS FOR CHANNEL '', Exec_Source_Log_Pos, 1) |
| 93 |
--let $assert_cond= [ SELECT "$applier_source_log_pos" = "0" ] |
| 94 |
--let $assert_text= The source log file position in the applier is 0 |
| 95 |
--source include/assert.inc |
| 96 |
|
| 97 |
--echo # |
| 98 |
--echo # 4. Test that the command times out cause positions are invalid |
| 99 |
|
| 100 |
--let $rpl_connection_name= server_2 |
| 101 |
--source include/rpl_connection.inc |
| 102 |
|
| 103 |
--let $source_post_wait_res = `SELECT SOURCE_POS_WAIT('$log_file_on_source', $log_pos_on_source, 2)` |
| 104 |
|
| 105 |
--let $assert_cond= [ SELECT "$source_post_wait_res" = "-1" ] |
| 106 |
--let $assert_text= The function timed out |
| 107 |
--source include/assert.inc |
| 108 |
|
| 109 |
--echo # |
| 110 |
--echo # 5. Execute a wait with a large timeout |
| 111 |
--echo # Turn applier positions valid again |
| 112 |
--echo # Check the function does not time out when positions become valid |
| 113 |
|
| 114 |
CREATE TABLE query_result(res INT); |
| 115 |
--replace_result $log_file_on_source LOG_FILE_ON_SOURCE $log_pos_on_source LOG_POS_ON_SOURCE |
| 116 |
--send_eval INSERT INTO query_result SELECT SOURCE_POS_WAIT('$log_file_on_source', $log_pos_on_source, 100); |
| 117 |
|
| 118 |
--source include/rpl_connection_slave.inc |
| 119 |
|
| 120 |
--source include/start_slave_io.inc |
| 121 |
|
| 122 |
--source include/rpl_connection_master.inc |
| 123 |
|
| 124 |
INSERT INTO t VALUES(3); |
| 125 |
|
| 126 |
--let $rpl_connection_name= server_2 |
| 127 |
--source include/rpl_connection.inc |
| 128 |
|
| 129 |
--reap |
| 130 |
|
| 131 |
--let $source_post_wait_res = `SELECT res FROM query_result` |
| 132 |
--let $assert_cond= [ SELECT "$source_post_wait_res" != "-1" ] |
| 133 |
--let $assert_text= The function did not time out |
| 134 |
--source include/assert.inc |
| 135 |
|
| 136 |
--echo # |
| 137 |
--echo # 6. SOURCE_POS_WAIT does not timeout when invoked with valid positioning info |
| 138 |
|
| 139 |
--source include/rpl_connection_slave.inc |
| 140 |
|
| 141 |
--let $source_post_wait_res = `SELECT SOURCE_POS_WAIT('$log_file_on_source', $log_pos_on_source, 30)` |
| 142 |
|
| 143 |
--let $assert_cond= [ SELECT "$source_post_wait_res" != "-1" ] |
| 144 |
--let $assert_text= The function did not time out |
| 145 |
--source include/assert.inc |
| 146 |
|
| 147 |
--echo # |
| 148 |
--echo # 7. Cleanup |
| 149 |
|
| 150 |
--source include/stop_slave.inc |
| 151 |
|
| 152 |
CHANGE REPLICATION SOURCE TO REQUIRE_ROW_FORMAT = 0, GTID_ONLY = 0; |
| 153 |
|
| 154 |
--source include/start_slave.inc |
| 155 |
|
| 156 |
CALL mtr.add_suppression("Relay log recovery on channel with GTID_ONLY=1*"); |
| 157 |
|
| 158 |
DROP TABLE query_result; |
| 159 |
|
| 160 |
--source include/rpl_connection_master.inc |
| 161 |
|
| 162 |
DROP TABLE t; |
| 163 |
|
| 164 |
--source include/rpl_end.inc |