Debian Codegraph @

mysql-test/suite/group_replication/t/gr_acf_master_retry.test

raw
1 ###############################################################################
2 # This test proves that ER_RPL_ASYNC_CHANNEL_CANT_CONNECT is thrown
3 # if connection cannot be established with any of the member in the
4 # replication_connection_configuration table to fetch status information.
5 #
6 # 0. This test needs 3 servers:
7 # server1: primary
8 # server2: secondary
9 # server3: single server replica
10 # 1. Start GR on M1(primary) and M2(secondary),
11 # and create user rpl_user.
12 # 2. Add asynchronous connection failover servers and
13 # verify that they are inserted successfully in
14 # performance_schema.replication_asynchronous_connection_failover.
15 # 3. Create and start new channel ch1_3: M3(replica), M1(source)
16 # and verify channel ch1_3 IO and SQL THREADS are ON.
17 # 4. Verify 2 senders are added automatically to
18 # replication_asynchronous_connection_failover table.
19 # 5. STOP GR on M1.
20 # 6. Verify error ER_RPL_ASYNC_CHANNEL_CANT_CONNECT is logged in M3.
21 # 7. Cleanup.
22 #
23 --source include/have_group_replication_plugin.inc
24 --let $rpl_skip_group_replication_start= 1
25 --let $rpl_group_replication_single_primary_mode=1
26 --let $rpl_server_count= 3
27 --source include/group_replication.inc
28
29 --echo
30 --echo # 1. Start GR on M1(primary) and M2(secondary),
31 --echo # and create user rpl_user.
32 --echo
33
34 --let $rpl_connection_name= server1
35 --source include/rpl_connection.inc
36
37 SET sql_log_bin=0;
38 CREATE USER 'rpl_user' IDENTIFIED BY '';
39 GRANT ALL PRIVILEGES ON *.* TO 'rpl_user';
40 FLUSH PRIVILEGES;
41 SET sql_log_bin=1;
42
43 --source include/start_and_bootstrap_group_replication.inc
44
45 --let $rpl_connection_name= server2
46 --source include/rpl_connection.inc
47
48 --source include/start_group_replication.inc
49
50 --echo
51 --echo # 2. Add asynchronous connection failover servers and
52 --echo # verify that they are inserted successfully in
53 --echo # performance_schema.replication_asynchronous_connection_failover.
54 --echo
55
56 --let $rpl_connection_name= server1
57 --source include/rpl_connection.inc
58 --let $_tmp_gr_group_name1= `SELECT @@GLOBAL.group_replication_group_name`
59
60 --let $rpl_connection_name= server3
61 --source include/rpl_connection.inc
62 --replace_result $SERVER_MYPORT_1 SERVER_MYPORT_1 $_tmp_gr_group_name1 GROUP_NAME
63 --eval SELECT asynchronous_connection_failover_add_managed('ch1_3', 'GroupReplication', '$_tmp_gr_group_name1', '127.0.0.1', $SERVER_MYPORT_1, '', 70, 60);
64
65 --let $assert_text= 'There is one row in performance_schema.replication_asynchronous_connection_failover'
66 --let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover, count, 1] = 1
67 --source include/assert.inc
68
69 --echo
70 --echo # 3. Create and start new channel ch1_3: M3(replica), M1(source)
71 --echo # and verify channel ch1_3 IO and SQL THREADS are ON.
72 --echo
73 --let $rpl_connection_name= server3
74 --source include/rpl_connection.inc
75
76 --replace_result $SERVER_MYPORT_1 SERVER_1_PORT
77 --eval CHANGE REPLICATION SOURCE TO SOURCE_HOST='127.0.0.1', SOURCE_USER='rpl_user' , SOURCE_AUTO_POSITION=1, SOURCE_CONNECTION_AUTO_FAILOVER=1, SOURCE_PORT=$SERVER_MYPORT_1, SOURCE_CONNECT_RETRY=1, SOURCE_RETRY_COUNT=2 for channel 'ch1_3'
78 --let $rpl_channel_name='ch1_3'
79 --source include/start_slave.inc
80 --let $rpl_channel_name=
81
82 --let $assert_text= Verify channel ch1_3 IO_THREAD is ON
83 --let $assert_cond= "[SELECT SERVICE_STATE FROM performance_schema.replication_connection_status WHERE channel_name = \'ch1_3\', SERVICE_STATE, 1]" = "ON"
84 --source include/assert.inc
85
86 --let $assert_text= Verify channel ch1_3 SQL_THREAD is ON
87 --let $assert_cond= "[SELECT SERVICE_STATE FROM performance_schema.replication_applier_status WHERE channel_name = \'ch1_3\', SERVICE_STATE, 1]" = "ON"
88 --source include/assert.inc
89
90 --echo
91 --echo # 4. Verify 2 senders are added automatically to
92 --echo # replication_asynchronous_connection_failover table.
93 --echo
94
95 --let $rpl_connection_name= server3
96 --source include/rpl_connection.inc
97
98 --let $wait_condition= SELECT COUNT(*)=2 FROM performance_schema.replication_asynchronous_connection_failover;
99 --source include/wait_condition.inc
100
101 --let $assert_text= 'Connected to server1 now.'
102 --let $assert_cond= [SELECT Port FROM performance_schema.replication_connection_configuration WHERE CHANNEL_NAME = \'ch1_3\', Port, 1] = $SERVER_MYPORT_1
103 --source include/assert.inc
104
105 --echo
106 --echo # 5. STOP GR on M1.
107 --echo
108
109 --let $rpl_connection_name= server1
110 --source include/rpl_connection.inc
111
112 --source include/stop_group_replication.inc
113
114 --echo
115 --echo # 6. Verify error ER_RPL_ASYNC_CHANNEL_CANT_CONNECT is logged in M3.
116 --echo
117
118 --let $rpl_connection_name= server3
119 --source include/rpl_connection.inc
120
121 # Managed channel is unable to connect to server2, as such
122 # replication_asynchronous_connection_failover is not updated.
123 --let $assert_text= 'Check that replication_asynchronous_connection_failover table has 2 rows.'
124 --let $assert_cond= [SELECT COUNT(*) as count FROM performance_schema.replication_asynchronous_connection_failover, count, 1]= 2
125 --source include/assert.inc
126
127 let $show_statement= SHOW SLAVE STATUS FOR CHANNEL 'ch1_3';
128 let $field= Last_IO_Errno;
129 let $condition= = '1045';
130 --source include/wait_show_condition.inc
131
132 --let $wait_condition= SELECT COUNT(*)>1 FROM performance_schema.error_log WHERE error_code='MY-010584' AND data LIKE "Replica I/O for channel 'ch1_3': Error connecting to source '[email protected]:%'. This was attempt 2/%, with a delay of 1 seconds between attempts. Message: Access denied for user 'rpl_user'@'localhost'%"
133 --source include/wait_condition.inc
134
135 --let $wait_condition= SELECT COUNT(*)=1 FROM performance_schema.error_log WHERE error_code='MY-013679' AND data LIKE "The Monitor IO thread failed to connect to the source % for channel 'ch1_3', thence it will try to connect to another source."
136 --source include/wait_condition.inc
137
138 --source include/wait_condition.inc
139
140 --let $wait_condition= SELECT COUNT(*)=1 FROM performance_schema.error_log WHERE error_code='MY-013679' AND data LIKE "The Monitor IO thread failed to connect to the source % for channel 'ch1_3', thence it will try to connect to another source."
141 --source include/wait_condition.inc
142
143
144 --echo
145 --echo # 7. Cleanup.
146 --echo
147
148 --let $rpl_connection_name= server1
149 --source include/rpl_connection.inc
150
151 SET sql_log_bin=0;
152 DROP USER 'rpl_user';
153 SET sql_log_bin=1;
154
155 --let $rpl_connection_name= server3
156 --source include/rpl_connection.inc
157
158 --let $rpl_channel_name='ch1_3'
159 --let $slave_error_param= Last_IO_Errno
160 --let $slave_io_errno=1045
161 --source include/stop_slave.inc
162 --let $slave_error_param=
163 --let $slave_io_errno=
164
165 --let $rpl_reset_slave_all= 1
166 --let $rpl_multi_source= 1
167 --source include/rpl_reset_slave.inc
168 --let $rpl_channel_name=
169 --let $rpl_reset_slave_all=
170 --let $rpl_multi_source=
171
172 --replace_result $group_replication_group_name GROUP_NAME
173 --eval SELECT asynchronous_connection_failover_delete_managed('ch1_3', '$group_replication_group_name')
174
175 SET SESSION sql_log_bin = 0;
176 call mtr.add_suppression("The source .* for channel 'ch1_3' has joined the group .*, and so added its entry into replication_asynchronous_connection_failover table.");
177 call mtr.add_suppression("The Monitor IO thread detected that the source .* does not belong to the group majority, thence the channel .* will try to connect to another source.*");
178 call mtr.add_suppression("The IO thread detected that the source .* does not belong to the group majority, thence the channel .* will try to connect to another source.");
179 call mtr.add_suppression("The Monitor IO thread failed to connect to the source .* for channel 'ch1_3', thence it will try to connect to another source.");
180 call mtr.add_suppression("The group .* for the channel .* has been removed, and so removed its entry from replication_asynchronous_connection_failover_managed and all the group members from replication_asynchronous_connection_failover table.");
181 call mtr.add_suppression("The group .* for the channel .* has been added, and so added its entry in replication_asynchronous_connection_failover_managed and source to replication_asynchronous_connection_failover table.");
182 SET SESSION sql_log_bin = 1;
183
184 --source include/group_replication_end.inc