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
|
# ==== Purpose ====
#
# WL#12649: Automatic reconnection for Async replication between InnoDB Clusters
#
# It verifies that replica does connects to sender added to
# performance_schema.replication_asynchronous_connection_failover even after
# replica restart after crash.
#
# ==== Implementation ====
#
# 1. Insert data on server1 and verify that its synced to the server 2.
# 2. Verify Asynchronous Replication Connection Failover is initially
# disabled. Also verify Asynchronous Replication is initially
# connected to server 1.
# 3. Enable Asynchronous Replication Connection Failover and set retry
# count and retry time to 2 and verify its enabled in
# performance_schema.replication_connection_configuration.
# 4. Add asynchronous connection failover server. Verify that they are
# inserted successfully in
# performance_schema.replication_asynchronous_connection_failover.
# 5. Initialize rpl_async_conn_failover_crash dbug sync point and stop
# server 1. The initialized dbug sync point will crash server 2.
# Reconnect to server 2 and start replica on it.
# 6. Verify that asynchronous replication channel gets connected to
# server 3 and also verify that asynchronous replication tries
# connecting to server 1 two (retry_count=2) times.
# 7. Clean up
#
--source include/not_valgrind.inc
--source include/have_debug.inc
--source include/have_debug_sync.inc
--let $rpl_server_count=3
--let $use_gtids= 1
--source include/master-slave.inc
--echo #
--echo # 1. Insert data on server1 and verify that its synced to the server 2.
--echo #
--let $rpl_connection_name= server_1
--source include/rpl_connection.inc
CREATE TABLE t1 (a INT) ENGINE = InnoDB;
INSERT INTO t1 VALUES (1);
--source include/rpl_sync.inc
--let $rpl_connection_name= server_2
--source include/rpl_connection.inc
--let $assert_text= 'There is one row on replica'
--let $assert_cond= [SELECT COUNT(*) count FROM t1, count, 1] = 1
--source include/assert.inc
--echo #
--echo # 2. Verify Asynchronous Replication Connection Failover is initially
--echo # disabled. Also verify Asynchronous Replication is initially
--echo # connected to server 1.
--echo #
--let $assert_text= 'Asynchronous Replication Connection Failover is disabled'
--let $assert_cond= [SELECT SOURCE_CONNECTION_AUTO_FAILOVER FROM performance_schema.replication_connection_configuration, SOURCE_CONNECTION_AUTO_FAILOVER, 1] = 0
--source include/assert.inc
--let $wait_condition= SELECT COUNT(*) = 1 FROM performance_schema.replication_connection_configuration WHERE CHANNEL_NAME='' AND PORT=$MASTER_MYPORT
--source include/wait_condition.inc
--echo #
--echo # 3. Enable Asynchronous Replication Connection Failover and set retry
--echo # count and retry time to 2 and verify its enabled in
--echo # performance_schema.replication_connection_configuration.
--echo #
--let $debug_point= async_conn_failover_disable_weight_check
--source include/add_debug_point.inc
--source include/stop_slave.inc
CHANGE REPLICATION SOURCE TO SOURCE_CONNECT_RETRY=1, SOURCE_RETRY_COUNT=2, SOURCE_CONNECTION_AUTO_FAILOVER=1;
--source include/start_slave.inc
# Verify Asynchronous Replication Connection Failover is enabled.
--let $assert_text= 'Asynchronous Replication Connection Failover is enabled'
--let $assert_cond= [SELECT SOURCE_CONNECTION_AUTO_FAILOVER FROM performance_schema.replication_connection_configuration, SOURCE_CONNECTION_AUTO_FAILOVER, 1] = 1
--source include/assert.inc
--echo #
--echo # 4. Add asynchronous connection failover server. Verify that they are
--echo # inserted successfully in
--echo # performance_schema.replication_asynchronous_connection_failover.
--echo #
--replace_result $SERVER_MYPORT_3 SERVER_MYPORT_3
--eval SELECT asynchronous_connection_failover_add_source('', '127.0.0.1', $SERVER_MYPORT_3, '', 50);
--let $assert_text= 'There are three rows in performance_schema.replication_asynchronous_connection_failover'
--let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover, count, 1] = 1
--source include/assert.inc
--echo #
--echo # 5. Initialize rpl_async_conn_failover_crash dbug sync point and stop
--echo # server 1. The initialized dbug sync point will crash server 2.
--echo # Reconnect to server 2 and start replica on it.
--echo #
--let $rpl_server_number= 2
--source include/rpl_start_server.inc
--let $debug_point= async_conn_failover_crash
--source include/add_debug_point.inc
--let $rpl_server_number= 1
--source include/rpl_stop_server.inc
# reconnect and start replica on server 2
--let $rpl_server_number= 2
--source include/rpl_reconnect.inc
--let $slave_error_param= Last_IO_Errno
--let $slave_io_errno=2003
--source include/start_slave.inc
--echo #
--echo # 6. Verify that asynchronous replication channel gets connected to
--echo # server 3 and also verify that asynchronous replication tries
--echo # connecting to server 1 two (retry_count=2) times.
--echo #
--let $wait_condition= SELECT COUNT(*) = 1 FROM performance_schema.replication_connection_configuration WHERE CHANNEL_NAME='' AND PORT=$SERVER_MYPORT_3
--source include/wait_condition.inc
# Verify that it tried connecting to server_1 two (retry_count=2) times.
--let $assert_text= Assert that the IO thread tried five times connecting to server_1
--let $assert_file=$MYSQLTEST_VARDIR/log/mysqld.2.err
--let $assert_select= .*Error reconnecting to source 'root@127.0.0.1:$SERVER_MYPORT_1'. This was attempt .*, with a delay of 1 seconds between attempts.*
--let $assert_only_after= CURRENT_TEST: rpl_gtid.rpl_async_conn_failover_restart
--let $assert_count= 2
--source include/assert_grep.inc
--echo #
--echo # 7. Clean up
--echo #
--let $rpl_connection_name= server_2
--source include/rpl_connection.inc
# Server crashed so debug points were cleaned
--source include/stop_slave.inc
--let $rpl_reset_slave_all= 1
--source include/rpl_reset_slave.inc
--let $rpl_reset_slave_all=
--replace_result $SERVER_MYPORT_3 SERVER_MYPORT_3
--eval SELECT asynchronous_connection_failover_delete_source('', '127.0.0.1', $SERVER_MYPORT_3, '');
DROP TABLE t1;
--let $rpl_connection_name= server_1
--source include/rpl_connection.inc
--let $rpl_server_number=1
--source include/rpl_start_server.inc
DROP TABLE t1;
--let $rpl_skip_sync= 1
--let $rpl_only_running_threads= 1
--source include/rpl_end.inc
|