Debian Codegraph @

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

raw
1 ###############################################################################
2 #
3 # Outside the scope of configurations changes, if a primary member fails
4 # the new primary wont be writable until it executes all
5 # the transactions from the old primary.
6 #
7 # Test:
8 # 0. This test requires three servers
9 # 1. Test starts in Single primary mode with server1 as primary
10 # 2. Set weight on server2 to be the next elected primary and join to
11 # the group
12 # 3. Add server3 to group
13 # 4. Lock table on the new primary (server 2)
14 # 5. Execute a transaction that will stuck
15 # 6. Stop server1
16 # 7. Server2 will wait for buffered transactions on read only mode
17 # 8. Unlock table on server2
18 # 9. Server2 will apply buffered transactions and disable read only mode
19 # 10. Assert server2 is primary server
20 # 11. Cleanup
21 #
22 ###############################################################################
23
24 --source include/big_test.inc
25 --source include/have_group_replication_plugin.inc
26 --let $rpl_skip_group_replication_start= 1
27 --let $rpl_group_replication_single_primary_mode=1
28 --let $rpl_server_count= 3
29 --source include/group_replication.inc
30
31 --echo
32 --echo # 1. Test starts in Single primary mode with server1 as primary
33
34 --let $server1_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1)
35
36 --source include/start_and_bootstrap_group_replication.inc
37
38 CREATE TABLE t1(a int primary key);
39
40 --let $rpl_connection_name= server2
41 --source include/rpl_connection.inc
42
43 --echo
44 --echo # 2. Set weight on server2 to be the next elected primary and join to
45 --echo # the group
46
47 SET @@GLOBAL.group_replication_member_weight= 90;
48
49 --source include/start_group_replication.inc
50
51 --echo
52 --echo # 3. Add server3 to group
53
54 --let $rpl_connection_name= server3
55 --source include/rpl_connection.inc
56
57 --source include/start_group_replication.inc
58
59 --echo
60 --echo # 4. Lock table on the new primary (server 2)
61
62 --let $rpl_connection_name= server_2
63 --source include/rpl_connection.inc
64
65 LOCK TABLE t1 READ;
66
67 --echo
68 --echo # 5. Execute a transaction that will stuck
69
70 --let $rpl_connection_name= server1
71 --source include/rpl_connection.inc
72
73 INSERT INTO t1 VALUES (1);
74
75 --echo
76 --echo # 6. Stop server1
77
78 --source include/stop_group_replication.inc
79
80 --echo
81 --echo # 7. Server2 will wait for buffered transactions on read only mode
82
83 --let $rpl_connection_name= server2
84 --source include/rpl_connection.inc
85
86 --let $wait_condition=SELECT COUNT(*)=1 FROM performance_schema.events_stages_current WHERE event_name LIKE "stage/group_rpl/Primary Election: applying buffered transactions"
87 --source include/wait_condition.inc
88
89 --let $wait_condition= SELECT @@GLOBAL.super_read_only = '1'
90 --source include/wait_condition.inc
91
92 --echo
93 --echo # 8. Unlock table on server2
94
95 --let $rpl_connection_name= server_2
96 --source include/rpl_connection.inc
97
98 UNLOCK TABLES;
99
100 --echo
101 --echo # 9. Server2 will apply buffered transactions and disable read only mode
102
103 --let $wait_condition= SELECT @@GLOBAL.super_read_only = '0'
104 --source include/wait_condition.inc
105
106 --echo
107 --echo # 10. Assert server2 is primary server
108
109 --source include/gr_assert_primary_member.inc
110
111 --echo
112 --echo # 11. Cleanup
113
114 --let $rpl_connection_name= server1
115 --source include/rpl_connection.inc
116
117 --source include/start_group_replication.inc
118
119 --let $rpl_connection_name= server2
120 --source include/rpl_connection.inc
121
122 SET @@GLOBAL.group_replication_member_weight= DEFAULT;
123 DROP TABLE t1;
124
125 --let $rpl_group_replication_reset_persistent_vars=1
126 --source include/group_replication_end.inc