Debian Codegraph @

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

raw
1 ################################################################################
2 #
3 # WL#10412: GR: notify listener services on relevant group events
4 #
5 # This test case checks that the correct notifications are
6 # triggered to the listeners registered in the service registry.
7 #
8 # For that it relies on a table that is updated by a listener
9 # through the SQL service API.
10 #
11 # This file covers the scenarios for regular bootstrap, join, leave, recovering.
12 #
13 # |------------+----+---------------------------------------------+------------+--------|
14 # | Tested | | Scenario\Where | | |
15 # | in this | | | Server | Others |
16 # | file | | | triggering | |
17 # | | | | event | |
18 # |------------+----+---------------------------------------------+------------+--------|
19 # | x | 1 | SERVER BOOTSTRAPS GROUP | VC,2xSC | N/A |
20 # | x | 2 | SERVER JOINS and STARTS RECOVERY | VC,SC | VC,SC |
21 # | x | 3 | SERVER RECOVERED | SC | SC |
22 # | x | 4 | SERVER LEAVES(ERROR), SERVER LEAVES(OFFLINE)| VC,SC | VC |
23 # |------------+----+---------------------------------------------+------------+--------|
24 # | | 5 | SERVER BOOTSTRAPS+RECOVERS+PRIMARY ELECTION | VC,RC,2xSC | |
25 # | | 6 | PRIMARY LEAVES | VC,SC,RC | VC,RC |
26 # |------------+----+---------------------------------------------+------------+--------|
27 # | | 7 | A SERVER BECOMES UNREACHABLE | SC, VC | N/A |
28 # | | 8 | MAJORITY UNREACHABLE | QL, SC | N/A |
29 # | | 9 | MAJORITY UNREACHABLE+FORCE MEMBERS | VC | N/A |
30 # | | 10 | MAJORITY UNREACHABLE+STOP | VC, SC | N/A |
31 # |------------+----+---------------------------------------------+------------+--------|
32 #
33 # Legend:
34 # - QL - Quorum Lost event
35 # - VC - View Changed event
36 # - RC - Role Changed event
37 # - SC - State Changed event
38 #
39 # To test the cases above, the test sets up a group of
40 # 2 servers in multi-master mode and proceeds to testing
41 # the different scenarios. These are highlighted in the
42 # test file.
43 ################################################################################
44
45 --source include/big_test.inc
46 --source include/have_debug.inc
47 --source include/have_debug_sync.inc
48 --source include/not_have_privilege_checks_user.inc
49 --source include/have_group_replication_plugin.inc
50 --source include/force_restart.inc
51
52 ###
53 ### Sets up the group with two servers: server1 and server2
54 ###
55
56 --let $rpl_skip_group_replication_start= 1
57 --source include/group_replication.inc
58
59 --let $rpl_connection_name= server1
60 --source include/rpl_connection.inc
61
62 # lets add the debug points and create the table into which
63 # the notifications will be logged.
64 --let $debug_point= register_gms_listener_example
65 --source include/add_debug_point.inc
66
67 SET SQL_LOG_BIN=0;
68 CREATE TABLE test.gms_listener_example(log_message TEXT);
69 SET SQL_LOG_BIN=1;
70
71 --let $rpl_connection_name= server2
72 --source include/rpl_connection.inc
73
74 --let $debug_point= register_gms_listener_example
75 --source include/add_debug_point.inc
76
77 SET SQL_LOG_BIN=0;
78 CREATE TABLE test.gms_listener_example(log_message TEXT);
79 SET SQL_LOG_BIN=1;
80
81 --echo ### Scenario 1: SERVER BOOTSTRAPS GROUP
82 --echo ### Expected:
83 --echo ### - Myself: 1 VIEW CHANGED, 2 STATE CHANGED
84 --echo ### - Others: N/A
85 --echo ##########################################################################
86
87 # start the group
88 --let $rpl_connection_name= server1
89 --source include/rpl_connection.inc
90 --source include/start_and_bootstrap_group_replication.inc
91
92 # view change + server moved to recovering then to online
93 --let $expected_notifications= 1,VIEW %:1|2,STATE %:1
94 --source ../include/assert_notifications.inc
95
96 --echo ### Scenario 2: MEMBER JOINS, but blocks recoverying
97 --echo ### Expected:
98 --echo ### - Myself: 1 VIEW CHANGED, 1 STATE CHANGED
99 --echo ### - Others: 1 VIEW CHANGED, 1 STATE CHANGED
100 --echo ##########################################################################
101
102 # server2
103
104 --let $rpl_connection_name= server2
105 --source include/rpl_connection.inc
106
107 SET @@GLOBAL.DEBUG='+d,recovery_thread_wait_before_finish';
108
109 --let $group_replication_start_member_state= RECOVERING
110 --source include/start_group_replication.inc
111
112 --let $expected_notifications= 1,VIEW %:2|1,STATE %:2
113 --source ../include/assert_notifications.inc
114
115 # server1
116
117 --let $rpl_connection_name= server1
118 --source include/rpl_connection.inc
119
120 --let $expected_notifications= 1,VIEW %:2|1,STATE %:2
121 --source ../include/assert_notifications.inc
122
123 --echo ### Scenario 3: MEMBER RECOVERS JOINS
124 --echo ### Expected:
125 --echo ### - Myself: 1 STATE CHANGED
126 --echo ### - Others: 1 STATE CHANGED
127 --echo ##########################################################################
128
129 --let $rpl_connection_name= server2
130 --source include/rpl_connection.inc
131
132 SET DEBUG_SYNC= "now WAIT_FOR signal.recovery_thread_wait_before_finish_reached";
133 SET @@GLOBAL.DEBUG='-d,recovery_thread_wait_before_finish';
134 SET DEBUG_SYNC= "now SIGNAL signal.recovery_end";
135
136 --let $group_replication_member_state= ONLINE
137 --source include/gr_wait_for_member_state.inc
138
139 --let $expected_notifications= 1,STATE %:2
140 --source ../include/assert_notifications.inc
141
142 --let $rpl_connection_name= server1
143 --source include/rpl_connection.inc
144
145 --let $expected_notifications= 1,STATE %:2
146 --source ../include/assert_notifications.inc
147
148 --echo ### Scenario 4: SERVER LEAVES(ERROR), SERVER LEAVES(OFFLINE)
149 --echo ### Expected:
150 --echo ### - Myself (leaving): 1 VIEW CHANGED, 1 STATE CHANGED
151 --echo ### - Others: 1 VIEW CHANGED
152 --echo ##########################################################################
153
154 # server2
155 --let $rpl_connection_name= server2
156 --source include/rpl_connection.inc
157
158 SET SESSION sql_log_bin=0;
159 call mtr.add_suppression("Table 'tab1' already exists");
160 call mtr.add_suppression("The applier thread execution was aborted. Unable to process more transactions, this member will now leave the group");
161 call mtr.add_suppression("Fatal error during execution on the Applier process of Group Replication. The server will now leave the group.");
162 call mtr.add_suppression("The server was automatically set into read only mode after an error was detected.");
163 call mtr.add_suppression("Replica SQL for channel 'group_replication_applier': ... The replica coordinator and worker threads are stopped,*");
164 SET SESSION sql_log_bin=1;
165
166 SET SESSION sql_log_bin=0;
167 CREATE TABLE test.tab1 (a INT PRIMARY KEY);
168 SET SESSION sql_log_bin=1;
169
170 # server1
171 --let $rpl_connection_name= server1
172 --source include/rpl_connection.inc
173 CREATE TABLE test.tab1 (a INT PRIMARY KEY);
174
175 # server2
176 --let $rpl_connection_name= server2
177 --source include/rpl_connection.inc
178
179 --let $group_replication_member_state= ERROR
180 --source include/gr_wait_for_member_state.inc
181
182 --let $expected_notifications= 1,STATE %:%|1,VIEW %:%
183 --source ../include/assert_notifications.inc
184
185 # server1
186 --let $rpl_connection_name= server1
187 --source include/rpl_connection.inc
188
189 --let $expected_notifications= 1,VIEW %:3
190 --source ../include/assert_notifications.inc
191
192 # server2
193 --let $rpl_connection_name= server2
194 --source include/rpl_connection.inc
195
196 --source include/stop_group_replication.inc
197
198 --let $group_replication_member_state= OFFLINE
199 --source include/gr_wait_for_member_state.inc
200
201 --let $expected_notifications= 1,STATE %:%
202 --source ../include/assert_notifications.inc
203
204 SET SESSION sql_log_bin=0;
205 DROP TABLE test.tab1;
206 SET SESSION sql_log_bin=1;
207
208 ###
209 ### Clean up and bail out
210 ###
211
212 # server1
213
214 --let $rpl_connection_name= server1
215 --source include/rpl_connection.inc
216
217 --source include/stop_group_replication.inc
218
219 --let $debug_point= register_gms_listener_example
220 --source include/remove_debug_point.inc
221
222 --source include/start_and_bootstrap_group_replication.inc
223
224 # server2
225
226 --let $rpl_connection_name= server2
227 --source include/rpl_connection.inc
228
229 --let $debug_point= register_gms_listener_example
230 --source include/remove_debug_point.inc
231 SET DEBUG_SYNC= 'RESET';
232
233 --source include/start_group_replication.inc
234
235 DROP TABLE gms_listener_example;
236 DROP TABLE test.tab1;
237 --source include/rpl_sync.inc
238
239 --source include/group_replication_end.inc