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