Debian Codegraph @

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

raw
1 ###############################################################################
2 #
3 # When the plugin is stopped or leaves in error, while changing
4 # from single primary mode to multi primary mode, if the member did
5 # not set the single primary mode flag to false, then update
6 # everywhere checks shall remain false.
7 #
8 # When the plugin is stopped or leaves in error, plugin configurations
9 # when the configuration change terminates must be valid,
10 # even if not persisted with SET PERSIST.
11 #
12 # Test:
13 # 0. This test requires three servers
14 # 1. Server1 start, bootstrap the group and create table test.t1
15 # 2. Start server2 and server3
16 # 3. Begin a transaction on server1
17 # 4. Execute action to switch to multi primary
18 # 5. Assert that action is waiting for a member
19 # 6. Restart a member, won't impact the success of action
20 # 7. The action continued on other servers and everyone is on MP
21 # 8. Check that Single primary mode is true on server 1 and the update
22 # everywhere checks are false.
23 # 9. Cleanup
24 #
25 ###############################################################################
26
27 --source include/big_test.inc
28 --source include/have_group_replication_plugin.inc
29 --let $rpl_server_count= 3
30 --let $rpl_skip_group_replication_start= 1
31 --let $rpl_group_replication_single_primary_mode=1
32 --source include/group_replication.inc
33
34 --echo
35 --echo # 1. Server1 start, bootstrap the group and create table test.t1
36
37 --source include/start_and_bootstrap_group_replication.inc
38
39 set session sql_log_bin=0;
40 call mtr.add_suppression("The function 'group_replication_switch_to_multi_primary_mode' failed. Member has left the group. This operation was locally aborted and for that reason terminated.");
41 set session sql_log_bin=1;
42
43 CREATE TABLE test.t1 (a INT PRIMARY KEY);
44
45 --echo
46 --echo # 2. Start server2 and server3
47
48 --let $rpl_connection_name= server2
49 --source include/rpl_connection.inc
50 --source include/start_group_replication.inc
51
52 --let $rpl_connection_name= server3
53 --source include/rpl_connection.inc
54 --source include/start_group_replication.inc
55
56 --echo
57 --echo # 3. Begin a transaction on server1
58
59 --let $rpl_connection_name= server1
60 --source include/rpl_connection.inc
61
62 BEGIN;
63 INSERT INTO t1 VALUES(1);
64
65 --echo
66 --echo # 4. Execute action to switch to multi primary
67
68 --let $rpl_connection_name= server_1_1
69 --source include/rpl_connection.inc
70
71 --send SELECT group_replication_switch_to_multi_primary_mode()
72
73 --echo
74 --echo # 5. Assert that action is waiting for a member
75
76 --let $rpl_connection_name= server2
77 --source include/rpl_connection.inc
78
79 --let $wait_condition=SELECT COUNT(*)=1 FROM performance_schema.events_stages_current WHERE event_name LIKE "%waiting on another member step%"
80 --source include/wait_condition.inc
81
82 --let $stage_name= `SELECT event_name FROM performance_schema.events_stages_current WHERE event_name LIKE "%stage/group_rpl%" AND event_name NOT LIKE "%stage/group_rpl/Group Replication%";`
83 --let $assert_text= stage/group_rpl/Multi-primary Switch: waiting on another member step completion
84 --let $assert_cond= "$stage_name" = "stage/group_rpl/Multi-primary Switch: waiting on another member step completion"
85 --source include/assert.inc
86
87 --echo
88 --echo # 6. Restart a member, won't impact the success of action
89
90 --let $rpl_connection_name= server_1
91 --source include/rpl_connection.inc
92
93 --source include/stop_group_replication.inc
94
95 --echo
96 --echo # 7. The action continued on other servers and everyone is on MP
97
98 --let $rpl_connection_name= server2
99 --source include/rpl_connection.inc
100
101 --source include/gr_assert_multi_primary_mode.inc
102
103 --let $rpl_connection_name= server3
104 --source include/rpl_connection.inc
105
106 --source include/gr_assert_multi_primary_mode.inc
107
108 --echo
109 --echo # 8. Check that Single primary mode is true on server 1 and the update
110 --echo # everywhere checks are false.
111
112 --let $rpl_connection_name= server_1_1
113 --source include/rpl_connection.inc
114
115 --error ER_GRP_RPL_UDF_ERROR
116 --reap
117
118 --let $assert_text= group_replication_enforce_update_everywhere_checks is OFF
119 --let $assert_cond= "[SELECT @@GLOBAL.group_replication_enforce_update_everywhere_checks]" = "0"
120 --source include/assert.inc
121
122 --let $assert_text= The single primary mode should be 1 here.
123 --let $assert_cond= "[SELECT @@GLOBAL.group_replication_single_primary_mode]" = 1;
124
125 --echo
126 --echo # 9. Cleanup
127
128 --let $rpl_connection_name= server1
129 --source include/rpl_connection.inc
130
131 ROLLBACK;
132
133 SET GLOBAL group_replication_single_primary_mode= OFF;
134 SET GLOBAL group_replication_enforce_update_everywhere_checks= ON;
135
136 --source include/start_group_replication.inc
137
138 --let $rpl_connection_name= server2
139 --source include/rpl_connection.inc
140
141 DROP TABLE t1;
142
143 --let $rpl_group_replication_reset_persistent_vars=1
144 --let $rpl_group_replication_single_primary_mode=1
145 --source include/group_replication_end.inc