Debian Codegraph @

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

raw
1 ################################################################################
2 # This test evaluates the functioning of the recovery reconnection options.
3 # 1) It sets the retry and reconnection time variables and checks their values
4 # 2) It verifies that the reconnection interval is respected by:
5 #
6 # Test:
7 # 0. The test requires three servers.
8 # 1. Starting 2 members and some data with no replication user for recovery
9 # 2. Set invalid recovery retries and check its value on 3rd member. Set invalid
10 # recovery reconnection interval and check its value on 3rd member.
11 # Start 3rd member with a reconnection interval of 1 minute and 3 retries.
12 # 3. With a configured recovery user, start member 3 and watch its state after
13 # 10 seconds. Recovery will fail to connect but it wont exhaust its 3
14 # configured retries so the state will still be "RECOVERING".
15 # 4. Configure replication users on the available donors.
16 # 5. Watch the member turning online after 60 seconds as on the last retry
17 # after the sleep the donors are now configured to accept the connection.
18 # 6. Clean up.
19 ################################################################################
20
21 --source include/big_test.inc
22 --let $group_replication_group_name=c827dcd0-2646-11e5-867f-0800200c9a66
23 --source include/have_group_replication_plugin.inc
24 --let $rpl_skip_group_replication_start= 1
25 --let $rpl_server_count= 3
26 --source include/group_replication.inc
27
28 --let $recovery_user= recovery_user
29 --let $recovery_password= recovery_password
30
31 --echo #
32 --echo # Start a group with 2 members and some data but no replication user
33 --echo #
34
35 --connection server1
36 --source include/start_and_bootstrap_group_replication.inc
37
38 #insert some data
39 CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
40 INSERT INTO t1 VALUES (1);
41
42 --echo #
43 --echo # Add some extra data on server 2 and then start group replication
44 --echo # Create a replication user so recovery can connect
45 --echo #
46
47 --connection server2
48 --source include/start_group_replication.inc
49
50 --echo #
51 --echo # On member 3:
52 --echo # Set the number of recovery retries and check its value
53 --echo # Set the recovery reconnection interval and check its value
54 --echo #
55
56 --connection server3
57
58 SET SESSION sql_log_bin= 0;
59 call mtr.add_suppression("There was an error when connecting to the donor*");
60 call mtr.add_suppression("Replica I/O for channel 'group_replication_recovery': Source command COM_REGISTER_REPLICA failed*");
61 call mtr.add_suppression("Replica I/O thread couldn't register on source*");
62 call mtr.add_suppression("For details please check performance_schema.replication_connection_status table and error log messages of Replica I/O for channel group_replication_recovery.");
63 SET SESSION sql_log_bin= 1;
64
65 SET @debug_save_rec_int= @@GLOBAL.group_replication_recovery_reconnect_interval;
66 SET @debug_save_retries= @@GLOBAL.group_replication_recovery_retry_count;
67
68 # Set invalid values. These should fail.
69 --error ER_WRONG_TYPE_FOR_VAR
70 SET GLOBAL group_replication_recovery_reconnect_interval= NULL;
71
72 --error ER_WRONG_TYPE_FOR_VAR
73 SET GLOBAL group_replication_recovery_reconnect_interval= "a";
74
75 --error ER_WRONG_TYPE_FOR_VAR
76 SET GLOBAL group_replication_recovery_reconnect_interval= 1.2;
77
78 --error ER_WRONG_TYPE_FOR_VAR
79 SET GLOBAL group_replication_recovery_retry_count= NULL;
80
81 --error ER_WRONG_TYPE_FOR_VAR
82 SET GLOBAL group_replication_recovery_retry_count= "a";
83
84 --error ER_WRONG_TYPE_FOR_VAR
85 SET GLOBAL group_replication_recovery_retry_count= 1.2;
86
87 # Set out of range values. These must truncate.
88 --disable_warnings
89 SET GLOBAL group_replication_recovery_reconnect_interval= -1;
90 --enable_warnings
91 --let $assert_text= The value for group_replication_recovery_reconnect_interval should be 0
92 --let $assert_cond= "[SELECT @@GLOBAL.group_replication_recovery_reconnect_interval]" = 0
93 --source include/assert.inc
94
95 --disable_warnings
96 SET GLOBAL group_replication_recovery_reconnect_interval= 31536001;
97 --enable_warnings
98 --let $assert_text= The value for group_replication_recovery_reconnect_interval should be 31536000
99 --let $assert_cond= "[SELECT @@GLOBAL.group_replication_recovery_reconnect_interval]" = 31536000
100 --source include/assert.inc
101
102 --disable_warnings
103 SET GLOBAL group_replication_recovery_retry_count= -1;
104 --enable_warnings
105 --let $assert_text= The value for group_replication_recovery_retry_count should be 0
106 --let $assert_cond= "[SELECT @@GLOBAL.group_replication_recovery_retry_count]" = 0
107 --source include/assert.inc
108
109 --disable_warnings
110 SET GLOBAL group_replication_recovery_retry_count= 31536001;
111 --enable_warnings
112 --let $assert_text= The value for group_replication_recovery_retry_count should be 31536000
113 --let $assert_cond= "[SELECT @@GLOBAL.group_replication_recovery_retry_count]" = 31536000
114 --source include/assert.inc
115
116 # Set the retry count to 3, one for each possible donor, plus one
117 --eval SET GLOBAL group_replication_recovery_retry_count= 3
118
119 --let $assert_text= The value of the recovery retry count should be 3
120 --let $assert_cond= "[SELECT @@group_replication_recovery_retry_count]" = "3"
121 --source include/assert.inc
122
123 # Wait one minute between attempts to connect to the group (the 2 donors)
124 --eval SET GLOBAL group_replication_recovery_reconnect_interval= 60
125
126 --let $assert_text= The value of the recovery reconnection interval should be 60 sec
127 --let $assert_cond= "[SELECT @@group_replication_recovery_reconnect_interval]" = "60"
128 --source include/assert.inc
129
130
131 --echo #
132 --echo # On member 3:
133 --echo # Set the recovery user and pass so it can't connect to any of the donors
134 --echo # After 10 second it should still be recovering, as the process is sleeping
135 --echo #
136
137 --connection server1
138 SET SESSION sql_log_bin= 0;
139 --eval CREATE USER "$recovery_user" IDENTIFIED BY "$recovery_password"
140 --eval GRANT GROUP_REPLICATION_STREAM ON *.* TO "$recovery_user"@'%';
141 FLUSH PRIVILEGES;
142 SET SESSION sql_log_bin= 1;
143
144 --connection server2
145 SET SESSION sql_log_bin= 0;
146 --eval CREATE USER "$recovery_user" IDENTIFIED BY "$recovery_password"
147 --eval GRANT GROUP_REPLICATION_STREAM ON *.* TO "$recovery_user"@'%';
148 FLUSH PRIVILEGES;
149 SET SESSION sql_log_bin= 1;
150
151 --connection server3
152 SET SESSION sql_log_bin= 0;
153 --eval CREATE USER "$recovery_user" IDENTIFIED BY "$recovery_password"
154 --eval GRANT GROUP_REPLICATION_STREAM ON *.* TO "$recovery_user"@'%';
155 FLUSH PRIVILEGES;
156 SET SESSION sql_log_bin= 1;
157
158 --disable_warnings
159 --eval CHANGE REPLICATION SOURCE TO SOURCE_USER="$recovery_user", SOURCE_PASSWORD="$recovery_password" FOR CHANNEL 'group_replication_recovery'
160 --enable_warnings
161
162 --eval SET GLOBAL group_replication_group_name= "$group_replication_group_name";
163 --source include/start_group_replication_command.inc
164
165 #give it time to fail twice and sleep
166 --sleep 10
167
168 --let $group_replication_member_state= RECOVERING
169 --source include/gr_wait_for_member_state.inc
170
171 --echo #
172 --echo # Create the recovery user on server 1 and server 2
173 --echo # The joiner should now connect to server 1 or 2 when failing over.
174 --echo #
175
176 --connection server1
177 SET SESSION sql_log_bin= 0;
178 --eval GRANT REPLICATION SLAVE ON *.* TO "$recovery_user"
179 FLUSH PRIVILEGES;
180 SET SESSION sql_log_bin= 1;
181
182 --connection server2
183 SET SESSION sql_log_bin= 0;
184 --eval GRANT REPLICATION SLAVE ON *.* TO "$recovery_user"
185 FLUSH PRIVILEGES;
186 SET SESSION sql_log_bin= 1;
187
188 --echo # After a minute, the node should failover on the last try and recover
189 --connection server3
190
191 # 80 sec sleep (the member should be online in 50 sec + 30 sec margin)
192 --let $wait_timeout= 80
193 --let $group_replication_member_state= ONLINE
194 --source include/gr_wait_for_member_state.inc
195
196 --let $assert_text= On the recovered member, the table should exist and have 1 elements
197 --let $assert_cond= [SELECT COUNT(*) FROM t1] = 1;
198 --source include/assert.inc
199
200 --echo #
201 --echo # Cleaning up
202 --echo #
203
204 SET @@GLOBAL.group_replication_recovery_reconnect_interval= @debug_save_rec_int;
205 SET @@GLOBAL.group_replication_recovery_retry_count= @debug_save_retries;
206
207 SET SESSION sql_log_bin= 0;
208 --eval DROP USER "$recovery_user"
209 SET SESSION sql_log_bin= 1;
210
211 DROP TABLE t1;
212
213 --connection server2
214
215 SET SESSION sql_log_bin= 0;
216 --eval DROP USER "$recovery_user"
217 SET SESSION sql_log_bin= 1;
218
219 --connection server1
220
221 SET SESSION sql_log_bin= 0;
222 --eval DROP USER "$recovery_user"
223 SET SESSION sql_log_bin= 1;
224
225 --source include/group_replication_end.inc