Debian Codegraph @

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

raw
1 ###############################################################################
2 #
3 # When electing a primary server, P, if any server S leaves or fails
4 # under a majority, the procedure shall not be affected and will resume.
5 #
6 # Test:
7 # 0. This test requires three servers
8 # 1. Start a group in single primary mode.
9 # 2. Go to a member that will be a secondary and lock a table
10 # 3. Insert a row on primary
11 # 4. Invoke a change the primary to server2
12 # 5. Check that the other members are waiting for members to be in read
13 # mode.
14 # Stages should be
15 # - Primary Election: waiting for members to enable super_read_only
16 # - Single-primary Switch: executing Primary election
17 # 6. Kill the stuck secondary
18 # 7. Check that the action finishes
19 # 8. Check that primary is now server2
20 # 9. Cleanup
21 #
22 ###############################################################################
23
24 --source include/big_test.inc
25 --source include/have_group_replication_plugin.inc
26 --source include/not_valgrind.inc
27 --let $rpl_server_count= 3
28 --let $rpl_skip_group_replication_start= 1
29 --let $rpl_group_replication_single_primary_mode=1
30 --source include/group_replication.inc
31
32 --echo
33 --echo # 1. Start a group in single primary mode.
34
35 --source include/start_and_bootstrap_group_replication.inc
36
37 --let $server1_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1)
38
39 CREATE TABLE test.t1 (a INT PRIMARY KEY);
40
41 --let $rpl_connection_name= server2
42 --source include/rpl_connection.inc
43
44 --source include/start_group_replication.inc
45
46 --let $server2_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1)
47
48 --echo
49 --echo # 2. Go to a member that will be a secondary and lock a table
50
51 --let $rpl_connection_name= server3
52 --source include/rpl_connection.inc
53 --source include/start_group_replication.inc
54
55 # Disable read only to be able to lock table
56 SET @@GLOBAL.read_only= 0;
57
58 LOCK TABLE t1 READ;
59
60 --echo
61 --echo # 3. Insert a row on primary
62
63 --let $rpl_connection_name= server1
64 --source include/rpl_connection.inc
65
66 INSERT INTO t1 VALUES (1);
67
68 --echo
69 --echo # 4. Invoke a change the primary to server2
70
71 --let $rpl_connection_name= server2
72 --source include/rpl_connection.inc
73
74 --replace_result $server2_uuid MEMBER2_UUID
75 --send_eval SELECT group_replication_set_as_primary("$server2_uuid")
76
77 --echo
78 --echo # 5. Check that the other members are waiting for members to be in read
79 --echo # mode.
80 --echo # Stages should be
81 --echo # - Primary Election: waiting for members to enable super_read_only
82 --echo # - Primary Switch: executing Primary election
83
84 --let $rpl_connection_name= server_2
85 --source include/rpl_connection.inc
86
87 --let $wait_condition=SELECT COUNT(*)=1 FROM performance_schema.events_stages_current WHERE event_name LIKE "%members to enable super_read_only%"
88 --source include/wait_condition.inc
89
90 --let $stage_name= `SELECT event_name FROM performance_schema.events_stages_current WHERE event_name LIKE "%Primary Switch%";`
91 --let $assert_text= stage/group_rpl/Primary Switch: executing Primary election
92 --let $assert_cond= "$stage_name" = "stage/group_rpl/Primary Switch: executing Primary election"
93 --source include/assert.inc
94
95 --let $stage_name= `SELECT event_name FROM performance_schema.events_stages_current WHERE event_name LIKE "%Primary Election:%";`
96 --let $assert_text= stage/group_rpl/Primary Election: waiting for members to enable super_read_only
97 --let $assert_cond= "$stage_name" = "stage/group_rpl/Primary Election: waiting for members to enable super_read_only"
98 --source include/assert.inc
99
100 --echo
101 --echo # 6. Kill the stuck secondary
102
103 --let $rpl_connection_name= server3
104 --source include/rpl_connection.inc
105
106 --let $_group_replication_local_address= `SELECT @@GLOBAL.group_replication_local_address`
107 --let $_group_replication_group_seeds= `SELECT @@GLOBAL.group_replication_group_seeds`
108 --let $_group_replication_comm_stack= `SELECT @@GLOBAL.group_replication_communication_stack`
109
110 --replace_result $group_replication_group_name GROUP_REPLICATION_GROUP_NAME $_group_replication_local_address GROUP_REPLICATION_LOCAL_ADDRESS $_group_replication_group_seeds GROUP_REPLICATION_GROUP_SEEDS $_group_replication_comm_stack GROUP_REPLICATION_COMMUNICATION_STACK
111 --let $restart_parameters=restart:--group-replication-start-on-boot=0 --group-replication-group-name=$group_replication_group_name --group_replication_local_address=$_group_replication_local_address --group_replication_group_seeds=$_group_replication_group_seeds --group_replication_single_primary_mode=TRUE --group_replication_enforce_update_everywhere_checks=FALSE --group_replication_communication_stack=$_group_replication_comm_stack
112 --source include/kill_and_restart_mysqld.inc
113
114 --let $rpl_server_number= 3
115 --source include/rpl_reconnect.inc
116
117 --echo
118 --echo # 7. Check that the action finishes
119
120 --let $rpl_connection_name= server2
121 --source include/rpl_connection.inc
122
123 --replace_result $server2_uuid MEMBER2_UUID
124 --reap
125
126 --echo
127 --echo # 8. Check that primary is now server2
128
129 --source include/gr_assert_primary_member.inc
130
131 --let $rpl_connection_name= server1
132 --source include/rpl_connection.inc
133
134 --source include/gr_assert_secondary_member.inc
135
136 --echo
137 --echo # 9. Cleanup
138
139 --let $rpl_connection_name= server2
140 --source include/rpl_connection.inc
141
142
143 DROP TABLE t1;
144
145 --let $rpl_connection_name= server3
146 --source include/rpl_connection.inc
147
148 DROP TABLE t1;
149
150 --let $rpl_group_replication_single_primary_mode=1
151 --let $rpl_group_replication_reset_persistent_vars=1
152 --source include/group_replication_end.inc