Debian Codegraph @

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

raw
1 ###############################################################################
2 #
3 # When a primary election is running, executing an action it will fail
4 #
5 # Test:
6 # 0. This test requires three servers
7 # 1. Start server1 and bootstrap group
8 # 2. Configure server2 with weight to be next primary
9 # 3. Lock table to block primary election
10 # 4. Start server3
11 # 5. Insert data to prevent server2 set read only and block on primary
12 # election
13 # 6. Stop server1 and run primary election
14 # 7. Executing an action will fail, a primary election is running
15 # 8. Unlock table to primary election finish
16 # 9. Assert server2 is the new primary
17 # 10. Cleanup
18 #
19 ###############################################################################
20
21 --source include/big_test.inc
22 --source include/have_group_replication_plugin.inc
23 --let $rpl_server_count= 3
24 --let $rpl_skip_group_replication_start= 1
25 --let $rpl_group_replication_single_primary_mode=1
26 --source include/group_replication.inc
27
28 --echo
29 --echo # 1. Start server1 and bootstrap group
30
31 --source include/start_and_bootstrap_group_replication.inc
32
33 CREATE TABLE test.t1 (a INT PRIMARY KEY);
34
35 --echo
36 --echo # 2. Configure server2 with weight to be next primary
37
38 --let $rpl_connection_name= server2
39 --source include/rpl_connection.inc
40
41 SET GLOBAL group_replication_member_weight= 90;
42
43 --source include/start_group_replication.inc
44
45 --echo
46 --echo # 3. Lock table to block primary election
47
48 LOCK TABLE t1 READ;
49
50 --echo
51 --echo # 4. Start server3
52
53 --let $rpl_connection_name= server3
54 --source include/rpl_connection.inc
55
56 set session sql_log_bin=0;
57 call mtr.add_suppression("The function 'group_replication_switch_to_multi_primary_mode' failed. A primary election is occurring in the group. Wait for it to end.");
58 set session sql_log_bin=1;
59
60 --source include/start_group_replication.inc
61
62 --echo
63 --echo # 5. Insert data to prevent server2 set read only and block on primary
64 --echo # election
65
66 --let $rpl_connection_name= server1
67 --source include/rpl_connection.inc
68
69 INSERT INTO t1 VALUES (1);
70
71 --echo
72 --echo # 6. Stop server1 and run primary election
73
74 --source include/stop_group_replication.inc
75
76 --echo
77 --echo # 7. Executing an action will fail, a primary election is running
78
79 --let $rpl_connection_name= server3
80 --source include/rpl_connection.inc
81
82 --let $wait_condition=SELECT COUNT(*)=1 FROM performance_schema.events_stages_current WHERE event_name LIKE "%stage/group_rpl/Primary Election: waiting on current primary transaction execution%"
83 --source include/wait_condition.inc
84
85 --error ER_GRP_RPL_UDF_ERROR
86 SELECT group_replication_switch_to_multi_primary_mode();
87
88 --echo
89 --echo # 8. Unlock table to primary election finish
90
91 --let $rpl_connection_name= server2
92 --source include/rpl_connection.inc
93
94 UNLOCK TABLES;
95
96 --let $wait_condition= SELECT @@GLOBAL.super_read_only = '0'
97 --source include/wait_condition.inc
98
99 --echo
100 --echo # 9. Assert server2 is the new primary
101
102 --source include/gr_assert_primary_member.inc
103
104 --echo
105 --echo # 10. Cleanup
106
107 --let $rpl_connection_name= server1
108 --source include/rpl_connection.inc
109
110 --source include/start_group_replication.inc
111
112 --let $rpl_connection_name= server2
113 --source include/rpl_connection.inc
114
115 DROP TABLE t1;
116
117 SET GLOBAL group_replication_member_weight= DEFAULT;
118
119 --source include/group_replication_end.inc