| 1 |
################################################################################ |
| 2 |
# This test verifies correctness and stability of WL#7332 implementation |
| 3 |
# of State Exchange subprotocol. |
| 4 |
# |
| 5 |
# The structure is as the following. |
| 6 |
# 0. Initialization: |
| 7 |
# - The test requires four servers: M1, M2, M3 and M4. |
| 8 |
# - On M4 create a table t1. |
| 9 |
# 1. Bootstrap start a group on M4. Start GR on M3, M2 and M1. This is general |
| 10 |
# stability part when servers leave and join randomly. The test implements |
| 11 |
# the following transition: 4 -> 3 -> 2 -> 3 -> 4. The purpose is to prove no |
| 12 |
# hangup or crashes. |
| 13 |
# 2. Stop GR on M3, M4. Two members group that demonstrates some (feasible) of |
| 14 |
# primary component properties. |
| 15 |
# - Insert data in a table t1 on M1. Verify the same data in M2. |
| 16 |
# - Verify the number of members is 2 from P_S table on M2. |
| 17 |
# - Verify view_id is non-zero. |
| 18 |
# - View_id on M1 and M2 should be same. |
| 19 |
# - Initiate a transaction on M1 and stop GR on M2. Rollback the transaction. |
| 20 |
# 3. Proof of view-id monotonicity and group-wide consistency. |
| 21 |
# - Start GR on M2, M3 and M4. |
| 22 |
# - On M4 fetch view_id from P_S table and compare it with old view_id of M1. |
| 23 |
# Latest view_id must be an increased value. |
| 24 |
# - Verify on all the members that view_id is same. |
| 25 |
# 4. Clean up. |
| 26 |
################################################################################ |
| 27 |
--source include/big_test.inc |
| 28 |
--source include/not_valgrind.inc |
| 29 |
--let $group_replication_group_name= 8a94f357-aab4-11df-86ab-c80aa9429573 |
| 30 |
--source include/have_group_replication_plugin.inc |
| 31 |
--let $rpl_skip_group_replication_start= 1 |
| 32 |
--let $rpl_server_count= 4 |
| 33 |
--source include/group_replication.inc |
| 34 |
|
| 35 |
# |
| 36 |
# a counter to be used with source include/gr_error_out.inc |
| 37 |
# |
| 38 |
--let $group_replication_error_connection_number= 4 |
| 39 |
|
| 40 |
# |
| 41 |
# First prepare four members and manually create a table on each. |
| 42 |
# |
| 43 |
--connection server1 |
| 44 |
|
| 45 |
if (`select view_id <> 0 from performance_schema.replication_group_member_stats where member_id in (SELECT @@server_uuid)`) |
| 46 |
{ |
| 47 |
--echo incorrect non-zero view_id when the Member is never started. |
| 48 |
--source include/gr_error_out.inc |
| 49 |
--die |
| 50 |
} |
| 51 |
|
| 52 |
--connection server4 |
| 53 |
|
| 54 |
CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB; |
| 55 |
|
| 56 |
# |
| 57 |
# Part I. |
| 58 |
# |
| 59 |
# Restart four members few times to prove general stability. It should |
| 60 |
# be done carefully to not destroy the group by occasional |
| 61 |
# withdrawal more than group.number_of_members / 2 - 1 members at a |
| 62 |
# time, that is not more than 1 in the condition of this test. |
| 63 |
# The test implements the following transition: 4 -> 3 -> 2 -> 3 -> 4. |
| 64 |
# |
| 65 |
|
| 66 |
--disable_query_log |
| 67 |
--disable_result_log |
| 68 |
--let $include_silent= 1 |
| 69 |
|
| 70 |
--source include/start_and_bootstrap_group_replication.inc |
| 71 |
|
| 72 |
--let $s_cnt=3 |
| 73 |
while($s_cnt) |
| 74 |
{ |
| 75 |
--connection server$s_cnt |
| 76 |
--source include/start_group_replication.inc |
| 77 |
|
| 78 |
--dec $s_cnt |
| 79 |
} |
| 80 |
|
| 81 |
--let $group_replication_number_of_members= 4 |
| 82 |
--source include/gr_wait_for_number_of_members.inc |
| 83 |
|
| 84 |
--let $restart_cnt= 10 |
| 85 |
while($restart_cnt) |
| 86 |
{ |
| 87 |
--let $s_id1=`select 1 + floor(rand()*100 % 4)` |
| 88 |
|
| 89 |
--connection server$s_id1 |
| 90 |
|
| 91 |
STOP GROUP_REPLICATION; |
| 92 |
SET GLOBAL read_only= FALSE; |
| 93 |
|
| 94 |
--let $s_id2= $s_id1 |
| 95 |
while ($s_id2 == $s_id1) |
| 96 |
{ |
| 97 |
--let $s_id2=`select 1 + floor(rand()*100 % 4)` |
| 98 |
} |
| 99 |
--connection server$s_id2 |
| 100 |
|
| 101 |
# |
| 102 |
# Here is the care point: don't go stopping the 2nd member until |
| 103 |
# it's proved the previous one is out of the view. |
| 104 |
# |
| 105 |
--let $group_replication_number_of_members= 3 |
| 106 |
--source include/gr_wait_for_number_of_members.inc |
| 107 |
|
| 108 |
STOP GROUP_REPLICATION; |
| 109 |
SET GLOBAL read_only= FALSE; |
| 110 |
|
| 111 |
--connection server$s_id1 |
| 112 |
--source include/start_group_replication_command.inc |
| 113 |
|
| 114 |
--connection server$s_id2 |
| 115 |
--source include/start_group_replication.inc |
| 116 |
|
| 117 |
--let $group_replication_number_of_members= 4 |
| 118 |
--source include/gr_wait_for_number_of_members.inc |
| 119 |
|
| 120 |
--dec $restart_cnt |
| 121 |
} |
| 122 |
--let $include_silent= 0 |
| 123 |
--enable_result_log |
| 124 |
--enable_query_log |
| 125 |
|
| 126 |
#Check if all members are online |
| 127 |
--let $group_replication_number_of_members= 4 |
| 128 |
--source include/gr_wait_for_number_of_members.inc |
| 129 |
|
| 130 |
# |
| 131 |
# Part II. |
| 132 |
# |
| 133 |
# Form the 2 member group and verify view-id on each member, must be equal. |
| 134 |
# At forming make sure two extra members exits one by one so the quorum |
| 135 |
# is not get lost. |
| 136 |
# |
| 137 |
|
| 138 |
--connection server3 |
| 139 |
--source include/stop_group_replication.inc |
| 140 |
|
| 141 |
--connection server4 |
| 142 |
--let $group_replication_number_of_members= 3 |
| 143 |
--source include/gr_wait_for_number_of_members.inc |
| 144 |
|
| 145 |
--source include/stop_group_replication.inc |
| 146 |
|
| 147 |
--connection server1 |
| 148 |
--let $group_replication_number_of_members= 2 |
| 149 |
--source include/gr_wait_for_number_of_members.inc |
| 150 |
|
| 151 |
# end of forming. |
| 152 |
|
| 153 |
--connection server1 |
| 154 |
INSERT INTO t1 SET c1=1; |
| 155 |
|
| 156 |
--connection server2 |
| 157 |
|
| 158 |
# |
| 159 |
# Success in getting expected value indicates the Primary Component |
| 160 |
# is installed. Let's verify the # of members is as PS says |
| 161 |
# |
| 162 |
let $count= 1; |
| 163 |
let $table= t1; |
| 164 |
--source include/wait_until_rows_count.inc |
| 165 |
|
| 166 |
if (`SELECT COUNT(*) <> 2 from performance_schema.replication_group_members`) |
| 167 |
{ |
| 168 |
--echo Unexpected group membership. |
| 169 |
--source include/gr_error_out.inc |
| 170 |
--die |
| 171 |
} |
| 172 |
|
| 173 |
# By above the Primary Component of two group members installation is proved. |
| 174 |
# Let's check out view-id values. |
| 175 |
--connection server1 |
| 176 |
--let $view_id_server1=`select view_id from performance_schema.replication_group_member_stats where member_id in (SELECT @@server_uuid)` |
| 177 |
|
| 178 |
--connection server2 |
| 179 |
--let $view_id_server2=`select view_id from performance_schema.replication_group_member_stats where member_id in (SELECT @@server_uuid)` |
| 180 |
|
| 181 |
if ($view_id_server1 == 0) |
| 182 |
{ |
| 183 |
--echo view_id must be non-zero at this point. |
| 184 |
--source include/gr_error_out.inc |
| 185 |
--die |
| 186 |
} |
| 187 |
if ($view_id_server1 != $view_id_server2) |
| 188 |
{ |
| 189 |
--echo inconsistent view_id:s: $view_id_server1 != $view_id_server2 |
| 190 |
--source include/gr_error_out.inc |
| 191 |
--die |
| 192 |
} |
| 193 |
|
| 194 |
# |
| 195 |
# Verify the Primary Component property of aborting transactions |
| 196 |
# whose originator members left the Primary Component. |
| 197 |
# The policy is tentative, it might (should) be a subject of |
| 198 |
# softer treatment, e.g wait with aborting till a timeout elapses. |
| 199 |
# Yet it's tested 'cos it's there. |
| 200 |
# |
| 201 |
--connection server1 |
| 202 |
BEGIN; |
| 203 |
INSERT INTO t1 SET c1=2; |
| 204 |
# Split the group and see that the left alone server1 won't make |
| 205 |
# Primary Component out of itself. |
| 206 |
|
| 207 |
--connection server2 |
| 208 |
--source include/stop_group_replication.inc |
| 209 |
|
| 210 |
# TODO: implement COMMIT instead of the coded rollback |
| 211 |
--connection server1 |
| 212 |
rollback; |
| 213 |
|
| 214 |
# |
| 215 |
# Part III. |
| 216 |
# |
| 217 |
# Form the four member group, check up monotonic and group consistent view-id. |
| 218 |
# |
| 219 |
--connection server2 |
| 220 |
--source include/start_group_replication.inc |
| 221 |
|
| 222 |
--connection server3 |
| 223 |
--source include/start_group_replication.inc |
| 224 |
|
| 225 |
--connection server4 |
| 226 |
--source include/start_group_replication.inc |
| 227 |
|
| 228 |
--let $s_cnt=4 |
| 229 |
while ($s_cnt) |
| 230 |
{ |
| 231 |
--connection server$s_cnt |
| 232 |
--let $group_replication_number_of_members= 4 |
| 233 |
--source include/gr_wait_for_number_of_members.inc |
| 234 |
|
| 235 |
--dec $s_cnt |
| 236 |
} |
| 237 |
# |
| 238 |
# a proof of view-id is monotonic |
| 239 |
# |
| 240 |
--let $view_id_now=`select RIGHT(view_id, 2) from performance_schema.replication_group_member_stats where member_id in (SELECT @@server_uuid)` |
| 241 |
--let $view_id_server1_number= `SELECT RIGHT('$view_id_server1', 2)` |
| 242 |
if ($view_id_now <= $view_id_server1_number) |
| 243 |
{ |
| 244 |
--echo Unexpected non-increased view-id value. |
| 245 |
--source include/gr_error_out.inc |
| 246 |
--die |
| 247 |
} |
| 248 |
|
| 249 |
# |
| 250 |
# view-id cross group consistency |
| 251 |
# |
| 252 |
--let $s_cnt=3 |
| 253 |
while ($s_cnt) |
| 254 |
{ |
| 255 |
--connection server$s_cnt |
| 256 |
--let $view_id_now_s=`select RIGHT(view_id,2) from performance_schema.replication_group_member_stats where member_id in (SELECT @@server_uuid)` |
| 257 |
if ($view_id_now != $view_id_now_s) |
| 258 |
{ |
| 259 |
--echo The 4th member view inconsistent with that of $s_cnt. |
| 260 |
--source include/gr_error_out.inc |
| 261 |
--die |
| 262 |
} |
| 263 |
dec $s_cnt; |
| 264 |
} |
| 265 |
|
| 266 |
|
| 267 |
# |
| 268 |
# Cleanup |
| 269 |
# |
| 270 |
DROP TABLE t1; |
| 271 |
|
| 272 |
--source include/group_replication_end.inc |