Debian Codegraph @

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

raw
1 ################################################################################
2 #
3 # The auto-rejoin process is a mechanism that allows a server that left the
4 # group due to flaky network (either on his side or on the other members) to
5 # try to join again up to group_replication_autorejoin_tries number of times.
6 #
7 # This test shall verify that upon a member expel, if auto-rejoin is enabled,
8 # the expelled member will try to rejoin the group up to
9 # group_replication_autorejoin_tries number of times and that a switch of MPM
10 # to SPM won't hang after a rejoin.
11 #
12 # Test:
13 # 0) The test requires three servers.
14 # 1) Expel one of the members.
15 # 2) Verify that the expelled member will try to rejoin the group the number of
16 # times it is configured in group_replication_autorejoin_tries sysvar.
17 # 3) Verify that it manages to rejoin the group
18 # 4) Switch from multi-primary to single-primary.
19 # 5) Cleanup.
20 #
21 ################################################################################
22 --source include/big_test.inc
23 --source include/have_debug_sync.inc
24 --source include/linux.inc
25 --source include/have_group_replication_plugin.inc
26 #
27 # We manually start the group because we need to set the rejoin timeout before
28 # the START GROUP_REPLICATION command.
29 #
30 --let $rpl_skip_group_replication_start= 1
31 --let $rpl_server_count = 3
32 --source include/group_replication.inc
33
34 --echo
35 --echo ####
36 --echo # 0) The test requires three servers.
37 --echo ####
38 --echo
39 SET sql_log_bin = 0;
40 call mtr.add_suppression("Member was expelled from the group due to network failures, changing member status to ERROR.");
41 call mtr.add_suppression("The server was automatically set into read only mode after an error was detected.");
42 call mtr.add_suppression("Started auto-rejoin procedure attempt*");
43 call mtr.add_suppression("Auto-rejoin procedure attempt*");
44 SET sql_log_bin = 1;
45
46 --source include/gr_autorejoin_monitoring.inc
47
48 SET @debug_saved = @@GLOBAL.DEBUG;
49 SET @@GLOBAL.DEBUG='+d,group_replication_rejoin_short_retry';
50 SET @@GLOBAL.DEBUG='+d,group_replication_stop_before_rejoin';
51
52 --source include/start_and_bootstrap_group_replication.inc
53
54 --let $rpl_connection_name = server2
55 --source include/rpl_connection.inc
56
57 --source include/start_group_replication.inc
58
59 --let $rpl_connection_name = server3
60 --source include/rpl_connection.inc
61
62 --source include/start_group_replication.inc
63
64 --echo
65 --echo ####
66 --echo # 1) Expel one of the members.
67 --echo ####
68 --echo
69 --let $rpl_connection_name = server1
70 --source include/rpl_connection.inc
71
72 # First, enable auto-rejoin
73 SET GLOBAL group_replication_autorejoin_tries = 1;
74
75 # Force expel on member 1
76 --let $member_id = `SELECT @@GLOBAL.server_uuid`
77 --source include/gr_expel_member_from_group.inc
78
79 --echo
80 --echo ####
81 --echo # 2) Verify that the expelled member will try to rejoin the group the
82 --echo # number of it is configured in group_replication_autorejoin_tries
83 --echo # sysvar.
84 --echo ####
85 --echo
86 --let $rpl_connection_name = server1
87 --source include/rpl_connection.inc
88
89 SET DEBUG_SYNC = "now WAIT_FOR signal.autorejoin_waiting";
90
91 # Verify that it is currently running
92 --let $assert_text = Auto-rejoin should be running
93 --let $assert_cond = [SELECT IS_AUTOREJOIN_RUNNING()] = TRUE
94 --source include/assert.inc
95
96 --let $assert_text= super_read_only should be enabled
97 --let $assert_cond= [SELECT @@GLOBAL.super_read_only] = 1;
98 --source include/assert.inc
99
100 # Verify that it attempted one try
101 --let $assert_text = We should have attempted 1 rejoin
102 --let $assert_cond = [SELECT GET_NUMBER_RETRIES()] = 1
103 --source include/assert.inc
104
105 SET DEBUG_SYNC = "now SIGNAL signal.autorejoin_continue";
106
107 # Verify that the auto-rejoin process has terminated
108 --let $wait_condition = SELECT IS_AUTOREJOIN_RUNNING() = FALSE
109 --source include/wait_condition_or_abort.inc
110
111 --echo
112 --echo ####
113 --echo # 3) Verify that it manages to rejoin the group.
114 --echo ####
115 --echo
116 --let $group_replication_member_state = ONLINE
117 --let $group_replication_member_id = $member_id
118 --source include/gr_wait_for_member_state.inc
119
120 --let $group_replication_number_of_members = 3
121 --source include/gr_wait_for_number_of_members.inc
122
123 --let $rpl_connection_name = server2
124 --source include/rpl_connection.inc
125
126 --let $member2_id = `SELECT @@GLOBAL.server_uuid`
127
128 --let $group_replication_number_of_members = 3
129 --source include/gr_wait_for_number_of_members.inc
130
131 --let $rpl_connection_name = server3
132 --source include/rpl_connection.inc
133
134 --let $group_replication_number_of_members = 3
135 --source include/gr_wait_for_number_of_members.inc
136
137 --echo
138 --echo ####
139 --echo # 4) Switch from multi-primary to single-primary.
140 --echo ####
141 --echo
142 --let $rpl_connection_name = server2
143 --source include/rpl_connection.inc
144
145 # We switch to SPM with server2 as the primary - it shouldn't hang
146 --replace_result $member2_id MEMBER2_UUID
147 --eval SELECT group_replication_switch_to_single_primary_mode("$member2_id");
148
149 --let $rpl_connection_name = server1
150 --source include/rpl_connection.inc
151
152 --source include/gr_assert_secondary_member.inc
153
154 --echo
155 --echo ####
156 --echo # 5) Cleanup.
157 --echo ####
158 --echo
159 --let $rpl_connection_name = server2
160 --source include/rpl_connection.inc
161
162 SELECT group_replication_switch_to_multi_primary_mode();
163 ## We stop the plugin so we can reset the sysvars we modified
164 #--source include/stop_group_replication.inc
165 --let $rpl_connection_name = server1
166 --source include/rpl_connection.inc
167
168 SET @@GLOBAL.DEBUG = @debug_saved;
169 SET @@GLOBAL.group_replication_autorejoin_tries = default;
170 --source include/gr_end_autorejoin_monitoring.inc
171 --let $rpl_group_replication_reset_persistent_vars=1
172 --source include/group_replication_end.inc