Debian Codegraph @

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

raw
1 #
2 # The IO thread MUST not connect to RECOVERING group member and should
3 # get re-connect to ONLINE member of the group as recovery can take time
4 # and that would unnecessary delay receiver in getting binary logs.
5 #
6 # Test:
7 #
8 # 0. The test requires 3 servers:
9 # server1: primary
10 # server2: secondary
11 # server3: single server replica
12 # 1. Bootstrap group with server1
13 # 2. Lock server2 on recovery and join it to the group
14 # 3. Establish managed connection between server3 and server2 secondary
15 # and locked on recovery. Secondaries priority is higher than primary
16 # 4. Create and start new channel ch1_3: server2(source),
17 # server3(replica)
18 # 5. Confirm server1 and server2 members of group are added to
19 # performance_schema.replication_asynchronous_connection_failover.
20 # 6. Confirm connection is done with server1 due to server2 being on
21 # recovery.
22 # 7. Wait 30 seconds and validate that replica is still connected
23 # to server1.
24 # 8. After UNLOCK tables it shall reconnect to server2
25 # 9. Cleanup
26 #
27
28 --source include/have_group_replication_plugin.inc
29 --let $rpl_skip_group_replication_start= 1
30 --let $rpl_server_count= 3
31 --let $rpl_group_replication_single_primary_mode=1
32 --source include/group_replication.inc
33
34 --echo
35 --echo # 1. Bootstrap group with server1
36 --echo
37
38 --let $rpl_connection_name= server1
39 --source include/rpl_connection.inc
40
41 set session sql_log_bin=0;
42 CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY , b INT);
43 set session sql_log_bin=1;
44
45 --source include/start_and_bootstrap_group_replication.inc
46
47 INSERT INTO test.t1 (b) VALUES (1);
48
49 --let $member1_uuid = `SELECT @@GLOBAL.server_uuid`
50 --let $_tmp_gr_group_name= `SELECT @@GLOBAL.group_replication_group_name`
51
52 --echo
53 --echo # 2. Lock server2 on recovery and join it to the group
54 --echo
55
56 --let $rpl_connection_name= server2
57 --source include/rpl_connection.inc
58
59 set session sql_log_bin=0;
60 CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY , b INT);
61 set session sql_log_bin=1;
62
63 --let $rpl_connection_name= server_2
64 --source include/rpl_connection.inc
65
66 LOCK TABLES t1 READ;
67
68 --let $rpl_connection_name= server2
69 --source include/rpl_connection.inc
70
71 --let $member2_uuid = `SELECT @@GLOBAL.server_uuid`
72
73 --let $group_replication_start_member_state= RECOVERING
74 --source include/start_group_replication.inc
75
76 --echo
77 --echo # 3. Establish managed connection between server3 and server2 secondary
78 --echo # and locked on recovery. Secondaries priority is higher than primary
79 --echo
80
81 --let $rpl_connection_name= server3
82 --source include/rpl_connection.inc
83
84 set session sql_log_bin=0;
85 CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY , b INT);
86 set session sql_log_bin=1;
87
88 --replace_result $SERVER_MYPORT_2 SERVER_MYPORT_2 $_tmp_gr_group_name FAILOVER_GROUP_NAME
89 --eval SELECT asynchronous_connection_failover_add_managed('ch1_3', 'GroupReplication', '$_tmp_gr_group_name', '127.0.0.1', $SERVER_MYPORT_2, '', 60, 80);
90
91 --echo
92 --echo # 4. Create and start new channel ch1_3: server2(source),
93 --echo # server3(replica)
94 --echo
95
96 --replace_result $SERVER_MYPORT_2 SERVER_2_PORT
97 --eval CHANGE REPLICATION SOURCE TO SOURCE_HOST='127.0.0.1', SOURCE_USER='root', SOURCE_AUTO_POSITION=1, SOURCE_CONNECTION_AUTO_FAILOVER=1, SOURCE_PORT=$SERVER_MYPORT_2, SOURCE_CONNECT_RETRY=1, SOURCE_RETRY_COUNT=1 FOR CHANNEL 'ch1_3'
98
99 --let $rpl_channel_name='ch1_3'
100 --source include/start_slave.inc
101 --let $rpl_channel_name=
102
103 --echo
104 --echo # 5. Confirm server1 and server2 members of group are added to
105 --echo # performance_schema.replication_asynchronous_connection_failover.
106 --echo
107
108 --let $wait_condition= SELECT COUNT(*)=2 FROM performance_schema.replication_asynchronous_connection_failover;
109 --source include/wait_condition.inc
110
111 --echo
112 --echo # 6. Confirm connection is done with server1 due to server2 being on
113 --echo # recovery.
114 --echo
115
116 --let $wait_condition= SELECT COUNT(*)=1 COUNT FROM performance_schema.replication_connection_status WHERE channel_name = "ch1_3" AND source_uuid = "$member1_uuid"
117 --source include/wait_condition.inc
118
119 --echo
120 --echo # 7. Wait 30 seconds and validate that replica is still connected
121 --echo # to server1.
122 --echo
123
124 --sleep 30
125 --let $assert_text= Verify server1 is on replication_asynchronous_connection_failover
126 --let $assert_cond= [SELECT count(*) COUNT FROM performance_schema.replication_connection_status WHERE channel_name = "ch1_3" AND source_uuid = "$member1_uuid", COUNT, 1] = "1"
127 --source include/assert.inc
128
129 --echo
130 --echo # 8. After UNLOCK tables it shall reconnect to server2
131 --echo
132
133 --let $rpl_connection_name= server_2
134 --source include/rpl_connection.inc
135
136 UNLOCK TABLES;
137
138 --let $group_replication_member_state= ONLINE
139 --source include/gr_wait_for_member_state.inc
140
141 --let $rpl_connection_name= server3
142 --source include/rpl_connection.inc
143
144 --let $wait_condition= SELECT COUNT(*)=1 COUNT FROM performance_schema.replication_connection_status WHERE channel_name = "ch1_3" AND source_uuid = "$member2_uuid"
145 --source include/wait_condition.inc
146
147 --echo
148 --echo # 9. Cleanup
149 --echo
150
151 SET SESSION sql_log_bin = 0;
152 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.");
153 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.");
154 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.");
155 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.");
156 SET SESSION sql_log_bin = 1;
157
158
159 --let $rpl_channel_name='ch1_3'
160 --source include/stop_slave.inc
161
162 --let $rpl_reset_slave_all= 1
163 --let $rpl_multi_source= 1
164 --source include/rpl_reset_slave.inc
165 --let $rpl_channel_name=
166 --let $rpl_reset_slave_all=
167 --let $rpl_multi_source=
168
169 --replace_result $group_replication_group_name GROUP_NAME
170 --eval SELECT asynchronous_connection_failover_delete_managed('ch1_3', '$group_replication_group_name')
171
172 DROP TABLE t1;
173
174 --let $rpl_connection_name= server1
175 --source include/rpl_connection.inc
176
177 DROP TABLE t1;
178
179 --let $rpl_skip_sync= 1
180 --let $rpl_only_running_threads= 1
181 --source include/group_replication_end.inc