Debian Codegraph @

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

raw
1 ################################################################################
2 # Validate group_replication_consistency= 'AFTER' against majority loss.
3 #
4 # Test:
5 # 00. The test requires three servers: M1, M2 and M3.
6 # 01. Create a table on the group.
7 # 02. Make server2 and 3 block before send its prepare message.
8 # This will allow us to deterministically remove it from the
9 # group while others are waiting for its acknowledge.
10 # The not acknowledged transaction must rollback on server 2 and 3.
11 # 03. Execute T1 on server1.
12 # 04. Wait until T1 is prepared on server3.
13 # 05. Crash server 2 and 3.
14 # Their state on server1 will be UNREACHABLE and the group
15 # will loose the majority.
16 # 06. server1 is waiting for the acknowledges, it will not
17 # proceed until the group majority is reestablished.
18 # 07. Unblock the group by forcing its membership to be only
19 # server1.
20 # 08. T1 did complete on server1.
21 # 09. T1 did not complete on server 2 and 3.
22 # 10. Clean up.
23 ################################################################################
24 # Don't test this under valgrind, memory leaks will occur
25 --source include/not_valgrind.inc
26 --source include/have_debug_sync.inc
27 --source include/force_restart.inc
28 --source include/have_group_replication_plugin.inc
29 --let $rpl_server_count= 3
30 --source include/group_replication.inc
31
32 --echo
33 --echo ############################################################
34 --echo # 01. Create a table on the group.
35 --let $rpl_connection_name= server1
36 --source include/rpl_connection.inc
37 CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY);
38
39 --let $rpl_connection_name= server1
40 --source include/rpl_connection.inc
41 --let $member1_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1)
42
43 --let $rpl_connection_name= server2
44 --source include/rpl_connection.inc
45 --let $member2_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1)
46
47 --let $rpl_connection_name= server3
48 --source include/rpl_connection.inc
49 --let $member3_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1)
50
51
52 --echo
53 --echo ############################################################
54 --echo # 02. Make server2 and 3 block before send its prepare message.
55 --echo # This will allow us to deterministically remove it from the
56 --echo # group while others are waiting for its acknowledge.
57 --echo # The not acknowledged transaction must rollback on server 2 and 3.
58 --let $rpl_connection_name= server2
59 --source include/rpl_connection.inc
60 SET @@GLOBAL.DEBUG= '+d,group_replication_wait_on_supress_message_send_after_applier_prepare';
61
62 --let $rpl_connection_name= server3
63 --source include/rpl_connection.inc
64 SET @@GLOBAL.DEBUG= '+d,group_replication_wait_on_supress_message_send_after_applier_prepare';
65
66
67 --echo
68 --echo ############################################################
69 --echo # 03. Execute T1 on server1.
70 --let $rpl_connection_name= server1
71 --source include/rpl_connection.inc
72 --send INSERT INTO t1 VALUES (1)
73
74
75 --echo
76 --echo ############################################################
77 --echo # 04. Wait until T1 is prepared on server3.
78 --let $rpl_connection_name= server2
79 --source include/rpl_connection.inc
80 # Wait for the debug sync to be reached.
81 SET DEBUG_SYNC= "now WAIT_FOR signal.after_supress_message_send_after_applier_prepare_waiting";
82
83 --let $rpl_connection_name= server3
84 --source include/rpl_connection.inc
85 # Wait for the debug sync to be reached.
86 SET DEBUG_SYNC= "now WAIT_FOR signal.after_supress_message_send_after_applier_prepare_waiting";
87
88
89 --echo
90 --echo ############################################################
91 --echo # 05. Crash server 2 and 3.
92 --echo # Their state on server1 will be UNREACHABLE and the group
93 --echo # will loose the majority.
94 # We do kill the servers, using shutdown_server 0, and then MTR will
95 # follow the expect file and restart the server, but we do not wait
96 # for the server restart.
97 # Since the servers loose its GCS configuration them will not rejoin
98 # the group.
99 --let $rpl_connection_name= server2
100 --source include/rpl_connection.inc
101 --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
102 --shutdown_server 0
103 --source include/wait_until_disconnected.inc
104
105 --let $rpl_connection_name= server3
106 --source include/rpl_connection.inc
107 --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.3.expect
108 --shutdown_server 0
109 --source include/wait_until_disconnected.inc
110
111 --let $rpl_connection_name= server_1
112 --source include/rpl_connection.inc
113 --let $group_replication_member_state= UNREACHABLE
114 --let $group_replication_member_id= $member2_uuid
115 --source include/gr_wait_for_member_state.inc
116
117 --let $group_replication_member_state= UNREACHABLE
118 --let $group_replication_member_id= $member3_uuid
119 --source include/gr_wait_for_member_state.inc
120
121 --let $group_replication_member_id= $member1_uuid
122
123
124 --echo
125 --echo ############################################################
126 --echo # 06. server1 is waiting for the acknowledges, it will not
127 --echo # proceed until the group majority is reestablished.
128 --let $rpl_connection_name= server_1
129 --source include/rpl_connection.inc
130 --let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist WHERE user='root' AND state='waiting for handler commit' AND info='INSERT INTO t1 VALUES (1)'
131 --source include/wait_condition.inc
132
133
134 --echo
135 --echo ############################################################
136 --echo # 07. Unblock the group by forcing its membership to be only
137 --echo # server1.
138 --let $member1_local_address= `SELECT @@GLOBAL.group_replication_local_address`
139 --replace_result $member1_local_address MEMBER1_LOCAL_ADDRESS
140 --eval SET GLOBAL group_replication_force_members= "$member1_local_address"
141
142
143 --echo
144 --echo ############################################################
145 --echo # 08. T1 did complete on server1.
146 --let $rpl_connection_name= server1
147 --source include/rpl_connection.inc
148 --reap
149
150 --let $assert_text= 'There is 1 value in table t1'
151 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE c1=1, count, 1] = 1
152 --source include/assert.inc
153
154
155 --echo
156 --echo ############################################################
157 --echo # 09. T1 did not complete on server 2 and 3.
158 --let $rpl_connection_name= server_2
159 --source include/rpl_connection.inc
160 --let $rpl_server_number= 2
161 --source include/rpl_reconnect.inc
162 --let $assert_text= 'There are no values in table t1'
163 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1, count, 1] = 0
164 --source include/assert.inc
165
166 --let $rpl_connection_name= server_3
167 --source include/rpl_connection.inc
168 --let $rpl_server_number= 3
169 --source include/rpl_reconnect.inc
170 --let $assert_text= 'There are no values in table t1'
171 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1, count, 1] = 0
172 --source include/assert.inc
173
174
175 --echo
176 --echo ############################################################
177 --echo # 10. Clean up.
178 --let $rpl_connection_name= server1
179 --source include/rpl_connection.inc
180 DROP TABLE t1;
181
182 --let $rpl_connection_name= server_2
183 --source include/rpl_connection.inc
184 DROP TABLE t1;
185
186 --let $rpl_connection_name= server_3
187 --source include/rpl_connection.inc
188 DROP TABLE t1;
189
190 --source include/group_replication_end.inc