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 191 192 193 194 195 196 197
|
################################################################################
# This test confirms that server executed and applier retrieved GTIDs are
# logged when primary changes.
#
# Test:
# 0. The test requires three servers: M1, M2 and M3.
# 1. Bootstrap M1(primary) and create some transactions.
# 2. Start GR on M2 with higher member weight and start GR on M3.
# 3. Create some transactions on M1.
# Fake stopped applier on M2 and create more transactions on M1.
# Wait for transactions to reach M3.
# 4. Stop primary server M1.
# M2 will become next primary due to member weight.
# 5. Assert messages are present on error log of M2 and M3.
# M2 becomes primary and fails since M2 applier is stopped.
# M3 becomes primary on M2 failure.
# 6. Start GR on M1 and M2.
# Switch to single primary mode and assert message is displayed.
# 7. Cleanup.
################################################################################
--source include/have_debug.inc
--let $group_replication_group_name= a1a1a1a1-b1b1-c1c1-d1d1-00002222aabb
--source include/have_group_replication_plugin.inc
--let $rpl_server_count= 3
--let $rpl_skip_group_replication_start= 1
--let $rpl_group_replication_single_primary_mode=1
--source include/group_replication.inc
--echo
--echo # 1. Bootstrap M1(primary) and create some transactions.
--echo
--source include/start_and_bootstrap_group_replication.inc
CREATE TABLE t1 (a INT PRIMARY KEY);
INSERT INTO t1 values (1);
--echo
--echo # 2. Start GR on M2 with higher member weight and start GR on M3.
--echo
--let $rpl_connection_name= server2
--source include/rpl_connection.inc
--let $member2_uuid=query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1)
SET @member_weight2_save= @@GLOBAL.group_replication_member_weight;
SET GLOBAL group_replication_member_weight= 90;
--source include/start_group_replication.inc
--let $rpl_connection_name= server3
--source include/rpl_connection.inc
--let $member3_uuid=query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1)
--source include/start_group_replication.inc
--echo
--echo # 3. Create some transactions on M1.
--echo # Fake Stopped applier on M2 and create more transactions on M1.
--echo # Wait for transactions to reach M3.
--echo
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
INSERT INTO t1 values (2);
INSERT INTO t1 values (3);
--source include/rpl_sync.inc
--let $rpl_connection_name= server2
--source include/rpl_connection.inc
SET @@GLOBAL.DEBUG= '+d,group_replication_wait_for_gtid_execution_force_error';
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
INSERT INTO t1 values (4);
INSERT INTO t1 values (5);
--let $rpl_connection_name= server3
--source include/rpl_connection.inc
--let $wait_condition=SELECT COUNT(*)=5 FROM test.t1
--source include/wait_condition.inc
--echo
--echo # 4. Stop primary server M1.
--echo # M2 will become next primary due to member weight.
--echo
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
--source include/stop_group_replication.inc
--echo
--echo # 5. Assert messages are present on error log of M2 and M3.
--echo # M2 becomes primary and fails since M2 applier is stopped.
--echo # M3 becomes primary on M2 failure.
--echo
--let $rpl_connection_name= server2
--source include/rpl_connection.inc
--let $group_replication_member_state= ERROR
--source include/gr_wait_for_member_state.inc
SET @@GLOBAL.DEBUG= '-d,group_replication_wait_for_gtid_execution_force_error';
## ASSERTS
--let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.2.err
--let $assert_count = 1
--let $assert_select = Elected primary member gtid_executed: a1a1a1a1-b1b1-c1c1-d1d1-00002222aabb:1-9
--let $assert_text = Server executed GTID set is logged.
--source include/assert_grep.inc
--let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.2.err
--let $assert_count = 1
--let $assert_select = Elected primary member applier channel received_transaction_set: a1a1a1a1-b1b1-c1c1-d1d1-00002222aabb:1-9
--let $assert_text = Applier retrieved GTID set is logged.
--source include/assert_grep.inc
## Server2 applier is stopped so it will become primary and fail.
## This helps us to avoid debug point before applier_wait.
--let $rpl_connection_name= server3
--source include/rpl_connection.inc
--let $group_replication_expected_uuid=query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1)
--source include/gr_wait_primary_member_uuid.inc
## ASSERTS
--let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.3.err
--let $assert_count = 1
--let $assert_select = Elected primary member gtid_executed: a1a1a1a1-b1b1-c1c1-d1d1-00002222aabb:1-9
--let $assert_text = Server executed GTID set is logged.
--source include/assert_grep.inc
--let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.3.err
--let $assert_count = 1
--let $assert_select = Elected primary member applier channel received_transaction_set: a1a1a1a1-b1b1-c1c1-d1d1-00002222aabb:5-9
--let $assert_text = Applier retrieved GTID set is logged.
--source include/assert_grep.inc
--echo
--echo # 6. Start GR on M1 and M2.
--echo # Switch to single primary mode and assert message is displayed.
--echo
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
--source include/start_group_replication.inc
--let $rpl_connection_name= server2
--source include/rpl_connection.inc
--source include/stop_group_replication.inc
--source include/start_group_replication.inc
--let $rpl_connection_name= server3
--source include/rpl_connection.inc
SELECT group_replication_switch_to_multi_primary_mode();
DROP table t1;
--source include/rpl_sync.inc
--replace_result $member2_uuid MEMBER2_UUID
--eval SELECT group_replication_switch_to_single_primary_mode("$member2_uuid")
## ASSERTS
--let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.2.err
--let $assert_count = 1
--let $assert_select = Elected primary member gtid_executed: a1a1a1a1-b1b1-c1c1-d1d1-00002222aabb:1-12
--let $assert_text = Server executed GTID set is logged.
--source include/assert_grep.inc
--let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.2.err
--let $assert_count = 1
--let $assert_select = Elected primary member applier channel received_transaction_set: a1a1a1a1-b1b1-c1c1-d1d1-00002222aabb:1-9:11-12
--let $assert_text = Applier retrieved GTID set is logged.
--source include/assert_grep.inc
--echo
--echo # 7. Cleanup.
--echo
--let $rpl_connection_name= server2
--source include/rpl_connection.inc
SET SESSION sql_log_bin= 0;
call mtr.add_suppression("There was an issue on the primary election process: Could not wait for the execution of local transactions. The member will now leave the group.");
call mtr.add_suppression("The server was automatically set into read only mode after an error was detected.");
call mtr.add_suppression("Skipping leave operation: concurrent attempt to leave the group is on-going.");
SET SESSION sql_log_bin= 1;
SET GLOBAL group_replication_member_weight= @member_weight2_save;
--let $rpl_group_replication_reset_persistent_vars=1
--source include/group_replication_end.inc
|