| 1 |
# ==== Purpose ==== |
| 2 |
# |
| 3 |
# WL#12649: Automatic reconnection for Async replication between InnoDB Clusters |
| 4 |
# |
| 5 |
# It verifies that replica does connects to sender added to |
| 6 |
# performance_schema.replication_asynchronous_connection_failover even after |
| 7 |
# replica restart after crash. |
| 8 |
# |
| 9 |
# ==== Implementation ==== |
| 10 |
# |
| 11 |
# 1. Insert data on server1 and verify that its synced to the server 2. |
| 12 |
# 2. Verify Asynchronous Replication Connection Failover is initially |
| 13 |
# disabled. Also verify Asynchronous Replication is initially |
| 14 |
# connected to server 1. |
| 15 |
# 3. Enable Asynchronous Replication Connection Failover and set retry |
| 16 |
# count and retry time to 2 and verify its enabled in |
| 17 |
# performance_schema.replication_connection_configuration. |
| 18 |
# 4. Add asynchronous connection failover server. Verify that they are |
| 19 |
# inserted successfully in |
| 20 |
# performance_schema.replication_asynchronous_connection_failover. |
| 21 |
# 5. Initialize rpl_async_conn_failover_crash dbug sync point and stop |
| 22 |
# server 1. The initialized dbug sync point will crash server 2. |
| 23 |
# Reconnect to server 2 and start replica on it. |
| 24 |
# 6. Verify that asynchronous replication channel gets connected to |
| 25 |
# server 3 and also verify that asynchronous replication tries |
| 26 |
# connecting to server 1 two (retry_count=2) times. |
| 27 |
# 7. Clean up |
| 28 |
# |
| 29 |
--source include/not_valgrind.inc |
| 30 |
--source include/have_debug.inc |
| 31 |
--source include/have_debug_sync.inc |
| 32 |
|
| 33 |
--let $rpl_server_count=3 |
| 34 |
--let $use_gtids= 1 |
| 35 |
--source include/master-slave.inc |
| 36 |
|
| 37 |
--echo # |
| 38 |
--echo # 1. Insert data on server1 and verify that its synced to the server 2. |
| 39 |
--echo # |
| 40 |
--let $rpl_connection_name= server_1 |
| 41 |
--source include/rpl_connection.inc |
| 42 |
CREATE TABLE t1 (a INT) ENGINE = InnoDB; |
| 43 |
INSERT INTO t1 VALUES (1); |
| 44 |
|
| 45 |
--source include/rpl_sync.inc |
| 46 |
|
| 47 |
|
| 48 |
--let $rpl_connection_name= server_2 |
| 49 |
--source include/rpl_connection.inc |
| 50 |
|
| 51 |
--let $assert_text= 'There is one row on replica' |
| 52 |
--let $assert_cond= [SELECT COUNT(*) count FROM t1, count, 1] = 1 |
| 53 |
--source include/assert.inc |
| 54 |
|
| 55 |
|
| 56 |
--echo # |
| 57 |
--echo # 2. Verify Asynchronous Replication Connection Failover is initially |
| 58 |
--echo # disabled. Also verify Asynchronous Replication is initially |
| 59 |
--echo # connected to server 1. |
| 60 |
--echo # |
| 61 |
--let $assert_text= 'Asynchronous Replication Connection Failover is disabled' |
| 62 |
--let $assert_cond= [SELECT SOURCE_CONNECTION_AUTO_FAILOVER FROM performance_schema.replication_connection_configuration, SOURCE_CONNECTION_AUTO_FAILOVER, 1] = 0 |
| 63 |
--source include/assert.inc |
| 64 |
|
| 65 |
--let $wait_condition= SELECT COUNT(*) = 1 FROM performance_schema.replication_connection_configuration WHERE CHANNEL_NAME='' AND PORT=$MASTER_MYPORT |
| 66 |
--source include/wait_condition.inc |
| 67 |
|
| 68 |
|
| 69 |
--echo # |
| 70 |
--echo # 3. Enable Asynchronous Replication Connection Failover and set retry |
| 71 |
--echo # count and retry time to 2 and verify its enabled in |
| 72 |
--echo # performance_schema.replication_connection_configuration. |
| 73 |
--echo # |
| 74 |
|
| 75 |
--let $debug_point= async_conn_failover_disable_weight_check |
| 76 |
--source include/add_debug_point.inc |
| 77 |
|
| 78 |
--source include/stop_slave.inc |
| 79 |
CHANGE REPLICATION SOURCE TO SOURCE_CONNECT_RETRY=1, SOURCE_RETRY_COUNT=2, SOURCE_CONNECTION_AUTO_FAILOVER=1; |
| 80 |
--source include/start_slave.inc |
| 81 |
|
| 82 |
# Verify Asynchronous Replication Connection Failover is enabled. |
| 83 |
--let $assert_text= 'Asynchronous Replication Connection Failover is enabled' |
| 84 |
--let $assert_cond= [SELECT SOURCE_CONNECTION_AUTO_FAILOVER FROM performance_schema.replication_connection_configuration, SOURCE_CONNECTION_AUTO_FAILOVER, 1] = 1 |
| 85 |
--source include/assert.inc |
| 86 |
|
| 87 |
|
| 88 |
--echo # |
| 89 |
--echo # 4. Add asynchronous connection failover server. Verify that they are |
| 90 |
--echo # inserted successfully in |
| 91 |
--echo # performance_schema.replication_asynchronous_connection_failover. |
| 92 |
--echo # |
| 93 |
|
| 94 |
--replace_result $SERVER_MYPORT_3 SERVER_MYPORT_3 |
| 95 |
--eval SELECT asynchronous_connection_failover_add_source('', '127.0.0.1', $SERVER_MYPORT_3, '', 50); |
| 96 |
|
| 97 |
--let $assert_text= 'There are three rows in performance_schema.replication_asynchronous_connection_failover' |
| 98 |
--let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover, count, 1] = 1 |
| 99 |
--source include/assert.inc |
| 100 |
|
| 101 |
|
| 102 |
--echo # |
| 103 |
--echo # 5. Initialize rpl_async_conn_failover_crash dbug sync point and stop |
| 104 |
--echo # server 1. The initialized dbug sync point will crash server 2. |
| 105 |
--echo # Reconnect to server 2 and start replica on it. |
| 106 |
--echo # |
| 107 |
|
| 108 |
--let $rpl_server_number= 2 |
| 109 |
--source include/rpl_start_server.inc |
| 110 |
|
| 111 |
--let $debug_point= async_conn_failover_crash |
| 112 |
--source include/add_debug_point.inc |
| 113 |
|
| 114 |
--let $rpl_server_number= 1 |
| 115 |
--source include/rpl_stop_server.inc |
| 116 |
|
| 117 |
# reconnect and start replica on server 2 |
| 118 |
--let $rpl_server_number= 2 |
| 119 |
--source include/rpl_reconnect.inc |
| 120 |
|
| 121 |
--let $slave_error_param= Last_IO_Errno |
| 122 |
--let $slave_io_errno=2003 |
| 123 |
--source include/start_slave.inc |
| 124 |
|
| 125 |
|
| 126 |
--echo # |
| 127 |
--echo # 6. Verify that asynchronous replication channel gets connected to |
| 128 |
--echo # server 3 and also verify that asynchronous replication tries |
| 129 |
--echo # connecting to server 1 two (retry_count=2) times. |
| 130 |
--echo # |
| 131 |
--let $wait_condition= SELECT COUNT(*) = 1 FROM performance_schema.replication_connection_configuration WHERE CHANNEL_NAME='' AND PORT=$SERVER_MYPORT_3 |
| 132 |
--source include/wait_condition.inc |
| 133 |
|
| 134 |
# Verify that it tried connecting to server_1 two (retry_count=2) times. |
| 135 |
--let $assert_text= Assert that the IO thread tried five times connecting to server_1 |
| 136 |
--let $assert_file=$MYSQLTEST_VARDIR/log/mysqld.2.err |
| 137 |
--let $assert_select= .*Error reconnecting to source '[email protected]:$SERVER_MYPORT_1'. This was attempt .*, with a delay of 1 seconds between attempts.* |
| 138 |
--let $assert_only_after= CURRENT_TEST: rpl_gtid.rpl_async_conn_failover_restart |
| 139 |
--let $assert_count= 2 |
| 140 |
--source include/assert_grep.inc |
| 141 |
|
| 142 |
|
| 143 |
--echo # |
| 144 |
--echo # 7. Clean up |
| 145 |
--echo # |
| 146 |
|
| 147 |
--let $rpl_connection_name= server_2 |
| 148 |
--source include/rpl_connection.inc |
| 149 |
|
| 150 |
# Server crashed so debug points were cleaned |
| 151 |
|
| 152 |
--source include/stop_slave.inc |
| 153 |
|
| 154 |
--let $rpl_reset_slave_all= 1 |
| 155 |
--source include/rpl_reset_slave.inc |
| 156 |
--let $rpl_reset_slave_all= |
| 157 |
|
| 158 |
--replace_result $SERVER_MYPORT_3 SERVER_MYPORT_3 |
| 159 |
--eval SELECT asynchronous_connection_failover_delete_source('', '127.0.0.1', $SERVER_MYPORT_3, ''); |
| 160 |
|
| 161 |
DROP TABLE t1; |
| 162 |
|
| 163 |
--let $rpl_connection_name= server_1 |
| 164 |
--source include/rpl_connection.inc |
| 165 |
|
| 166 |
--let $rpl_server_number=1 |
| 167 |
--source include/rpl_start_server.inc |
| 168 |
|
| 169 |
DROP TABLE t1; |
| 170 |
|
| 171 |
--let $rpl_skip_sync= 1 |
| 172 |
--let $rpl_only_running_threads= 1 |
| 173 |
--source include/rpl_end.inc |