Debian Codegraph @

mysql-test/suite/group_replication/t/gr_autorejoin_member_expel_rejoin_successful.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.
10 #
11 # Test:
12 # 0) The test requires three servers.
13 # 1) Expel one of the members.
14 # 2) Verify that the expelled member will try to rejoin the group the number of
15 # times it is configured in group_replication_autorejoin_tries sysvar.
16 # 3) Verify that it manages to rejoin the group
17 # 4) Cleanup.
18 #
19 ################################################################################
20 --source include/big_test.inc
21 --source include/have_debug_sync.inc
22 --source include/linux.inc
23 --source include/have_group_replication_plugin.inc
24 #
25 # We manually start the group because we need to set the rejoin timeout before
26 # the START GROUP_REPLICATION command.
27 #
28 --let $rpl_skip_group_replication_start= 1
29 --let $rpl_server_count = 3
30 --source include/group_replication.inc
31
32 --echo
33 --echo ####
34 --echo # 0) The test requires three servers.
35 --echo ####
36 --echo
37 SET sql_log_bin = 0;
38 call mtr.add_suppression("Member was expelled from the group due to network failures, changing member status to ERROR.");
39 call mtr.add_suppression("The server was automatically set into read only mode after an error was detected.");
40 call mtr.add_suppression("Started auto-rejoin procedure attempt*");
41 call mtr.add_suppression("Auto-rejoin procedure attempt*");
42 SET sql_log_bin = 1;
43
44 --source include/gr_autorejoin_monitoring.inc
45
46 SET @debug_saved = @@GLOBAL.DEBUG;
47 SET @@GLOBAL.DEBUG='+d,group_replication_rejoin_short_retry';
48 SET @@GLOBAL.DEBUG='+d,group_replication_stop_before_rejoin';
49
50 --source include/start_and_bootstrap_group_replication.inc
51
52 --let $rpl_connection_name = server2
53 --source include/rpl_connection.inc
54
55 --source include/start_group_replication.inc
56
57 --let $rpl_connection_name = server3
58 --source include/rpl_connection.inc
59
60 --source include/start_group_replication.inc
61
62 # Insert some data to be replicated
63 CREATE TABLE t1(a INT PRIMARY KEY);
64 INSERT INTO t1 VALUES(1);
65 INSERT INTO t1 VALUES(2);
66 INSERT INTO t1 VALUES(3);
67 INSERT INTO t1 VALUES(4);
68 --source include/rpl_sync.inc
69
70 --echo
71 --echo ####
72 --echo # 1) Expel one of the members.
73 --echo ####
74 --echo
75 --let $rpl_connection_name = server1
76 --source include/rpl_connection.inc
77
78 # First, enable auto-rejoin
79 SET GLOBAL group_replication_autorejoin_tries = 1;
80
81 # Force expel on member 1
82 --let $local_address_server = `SELECT @@GLOBAL.group_replication_local_address`
83 --let $group_seeds_server = `SELECT @@GLOBAL.group_replication_group_seeds`
84 --let $member_id = `SELECT @@GLOBAL.server_uuid`
85 --source include/gr_expel_member_from_group.inc
86
87 --let $rpl_connection_name = server2
88 --source include/rpl_connection.inc
89
90 # Data to be recovered when server 1 rejoins the group
91 INSERT INTO t1 VALUES(5);
92 --source include/rpl_sync.inc
93
94 --echo
95 --echo ####
96 --echo # 2) Verify that the expelled member will try to rejoin the group the
97 --echo # number of it is configured in group_replication_autorejoin_tries
98 --echo # sysvar.
99 --echo ####
100 --echo
101 --let $rpl_connection_name = server1
102 --source include/rpl_connection.inc
103
104 SET DEBUG_SYNC = "now WAIT_FOR signal.autorejoin_waiting";
105
106 # Verify that it is currently running
107 --let $assert_text = Auto-rejoin should be running
108 --let $assert_cond = [SELECT IS_AUTOREJOIN_RUNNING()] = TRUE
109 --source include/assert.inc
110
111 --let $assert_text= super_read_only should be enabled
112 --let $assert_cond= [SELECT @@GLOBAL.super_read_only] = 1;
113 --source include/assert.inc
114
115 # Verify that it attempted one try
116 --let $assert_text = We should have attempted 1 rejoin
117 --let $assert_cond = [SELECT GET_NUMBER_RETRIES()] = 1
118 --source include/assert.inc
119
120 SET DEBUG_SYNC = "now SIGNAL signal.autorejoin_continue";
121
122 # Verify that the auto-rejoin process has terminated
123 --let $wait_condition = SELECT IS_AUTOREJOIN_RUNNING() = FALSE
124 --source include/wait_condition_or_abort.inc
125
126 --echo
127 --echo ####
128 --echo # 3) Verify that it manages to rejoin the group.
129 --echo ####
130 --echo
131 --let $group_replication_member_state = ONLINE
132 --let $group_replication_member_id = $member_id
133 --source include/gr_wait_for_member_state.inc
134
135 --let $group_replication_number_of_members = 3
136 --source include/gr_wait_for_number_of_members.inc
137
138 --let $rpl_connection_name = server2
139 --source include/rpl_connection.inc
140
141 --let $group_replication_number_of_members = 3
142 --source include/gr_wait_for_number_of_members.inc
143
144 --let $rpl_connection_name = server3
145 --source include/rpl_connection.inc
146
147 --let $group_replication_number_of_members = 3
148 --source include/gr_wait_for_number_of_members.inc
149
150 # Verify that server 1 received all data from recovery after rejoining
151 --let $diff_tables=server1:t1, server2:t1, server3:t1
152 --source include/diff_tables.inc
153
154 --echo
155 --echo ####
156 --echo # 4) Cleanup.
157 --echo ####
158 --echo
159 --let $rpl_connection_name = server1
160 --source include/rpl_connection.inc
161
162 DROP TABLE t1;
163 SET @@GLOBAL.DEBUG = @debug_saved;
164 SET @@GLOBAL.group_replication_autorejoin_tries = default;
165 --source include/gr_end_autorejoin_monitoring.inc
166 --source include/group_replication_end.inc