| 1 |
################################################################################ |
| 2 |
# This test confirms that server executed and applier retrieved GTIDs are |
| 3 |
# logged when primary changes. |
| 4 |
# |
| 5 |
# Test: |
| 6 |
# 0. The test requires three servers: M1, M2 and M3. |
| 7 |
# 1. Bootstrap M1(primary) and create some transactions. |
| 8 |
# 2. Start GR on M2 with higher member weight and start GR on M3. |
| 9 |
# 3. Create some transactions on M1. |
| 10 |
# Fake stopped applier on M2 and create more transactions on M1. |
| 11 |
# Wait for transactions to reach M3. |
| 12 |
# 4. Stop primary server M1. |
| 13 |
# M2 will become next primary due to member weight. |
| 14 |
# 5. Assert messages are present on error log of M2 and M3. |
| 15 |
# M2 becomes primary and fails since M2 applier is stopped. |
| 16 |
# M3 becomes primary on M2 failure. |
| 17 |
# 6. Start GR on M1 and M2. |
| 18 |
# Switch to single primary mode and assert message is displayed. |
| 19 |
# 7. Cleanup. |
| 20 |
################################################################################ |
| 21 |
|
| 22 |
--source include/have_debug.inc |
| 23 |
--let $group_replication_group_name= a1a1a1a1-b1b1-c1c1-d1d1-00002222aabb |
| 24 |
--source include/have_group_replication_plugin.inc |
| 25 |
--let $rpl_server_count= 3 |
| 26 |
--let $rpl_skip_group_replication_start= 1 |
| 27 |
--let $rpl_group_replication_single_primary_mode=1 |
| 28 |
--source include/group_replication.inc |
| 29 |
|
| 30 |
--echo |
| 31 |
--echo # 1. Bootstrap M1(primary) and create some transactions. |
| 32 |
--echo |
| 33 |
--source include/start_and_bootstrap_group_replication.inc |
| 34 |
CREATE TABLE t1 (a INT PRIMARY KEY); |
| 35 |
INSERT INTO t1 values (1); |
| 36 |
|
| 37 |
--echo |
| 38 |
--echo # 2. Start GR on M2 with higher member weight and start GR on M3. |
| 39 |
--echo |
| 40 |
--let $rpl_connection_name= server2 |
| 41 |
--source include/rpl_connection.inc |
| 42 |
--let $member2_uuid=query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1) |
| 43 |
|
| 44 |
SET @member_weight2_save= @@GLOBAL.group_replication_member_weight; |
| 45 |
SET GLOBAL group_replication_member_weight= 90; |
| 46 |
--source include/start_group_replication.inc |
| 47 |
|
| 48 |
|
| 49 |
--let $rpl_connection_name= server3 |
| 50 |
--source include/rpl_connection.inc |
| 51 |
--let $member3_uuid=query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1) |
| 52 |
--source include/start_group_replication.inc |
| 53 |
|
| 54 |
--echo |
| 55 |
--echo # 3. Create some transactions on M1. |
| 56 |
--echo # Fake Stopped applier on M2 and create more transactions on M1. |
| 57 |
--echo # Wait for transactions to reach M3. |
| 58 |
--echo |
| 59 |
|
| 60 |
--let $rpl_connection_name= server1 |
| 61 |
--source include/rpl_connection.inc |
| 62 |
|
| 63 |
INSERT INTO t1 values (2); |
| 64 |
INSERT INTO t1 values (3); |
| 65 |
--source include/rpl_sync.inc |
| 66 |
|
| 67 |
--let $rpl_connection_name= server2 |
| 68 |
--source include/rpl_connection.inc |
| 69 |
|
| 70 |
SET @@GLOBAL.DEBUG= '+d,group_replication_wait_for_gtid_execution_force_error'; |
| 71 |
|
| 72 |
--let $rpl_connection_name= server1 |
| 73 |
--source include/rpl_connection.inc |
| 74 |
|
| 75 |
INSERT INTO t1 values (4); |
| 76 |
INSERT INTO t1 values (5); |
| 77 |
|
| 78 |
--let $rpl_connection_name= server3 |
| 79 |
--source include/rpl_connection.inc |
| 80 |
|
| 81 |
--let $wait_condition=SELECT COUNT(*)=5 FROM test.t1 |
| 82 |
--source include/wait_condition.inc |
| 83 |
|
| 84 |
--echo |
| 85 |
--echo # 4. Stop primary server M1. |
| 86 |
--echo # M2 will become next primary due to member weight. |
| 87 |
--echo |
| 88 |
|
| 89 |
--let $rpl_connection_name= server1 |
| 90 |
--source include/rpl_connection.inc |
| 91 |
|
| 92 |
--source include/stop_group_replication.inc |
| 93 |
|
| 94 |
--echo |
| 95 |
--echo # 5. Assert messages are present on error log of M2 and M3. |
| 96 |
--echo # M2 becomes primary and fails since M2 applier is stopped. |
| 97 |
--echo # M3 becomes primary on M2 failure. |
| 98 |
--echo |
| 99 |
--let $rpl_connection_name= server2 |
| 100 |
--source include/rpl_connection.inc |
| 101 |
|
| 102 |
--let $group_replication_member_state= ERROR |
| 103 |
--source include/gr_wait_for_member_state.inc |
| 104 |
|
| 105 |
SET @@GLOBAL.DEBUG= '-d,group_replication_wait_for_gtid_execution_force_error'; |
| 106 |
|
| 107 |
## ASSERTS |
| 108 |
--let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.2.err |
| 109 |
--let $assert_count = 1 |
| 110 |
--let $assert_select = Elected primary member gtid_executed: a1a1a1a1-b1b1-c1c1-d1d1-00002222aabb:1-9 |
| 111 |
--let $assert_text = Server executed GTID set is logged. |
| 112 |
--source include/assert_grep.inc |
| 113 |
|
| 114 |
--let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.2.err |
| 115 |
--let $assert_count = 1 |
| 116 |
--let $assert_select = Elected primary member applier channel received_transaction_set: a1a1a1a1-b1b1-c1c1-d1d1-00002222aabb:1-9 |
| 117 |
--let $assert_text = Applier retrieved GTID set is logged. |
| 118 |
--source include/assert_grep.inc |
| 119 |
|
| 120 |
## Server2 applier is stopped so it will become primary and fail. |
| 121 |
## This helps us to avoid debug point before applier_wait. |
| 122 |
--let $rpl_connection_name= server3 |
| 123 |
--source include/rpl_connection.inc |
| 124 |
|
| 125 |
--let $group_replication_expected_uuid=query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1) |
| 126 |
--source include/gr_wait_primary_member_uuid.inc |
| 127 |
|
| 128 |
## ASSERTS |
| 129 |
--let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.3.err |
| 130 |
--let $assert_count = 1 |
| 131 |
--let $assert_select = Elected primary member gtid_executed: a1a1a1a1-b1b1-c1c1-d1d1-00002222aabb:1-9 |
| 132 |
--let $assert_text = Server executed GTID set is logged. |
| 133 |
--source include/assert_grep.inc |
| 134 |
|
| 135 |
--let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.3.err |
| 136 |
--let $assert_count = 1 |
| 137 |
--let $assert_select = Elected primary member applier channel received_transaction_set: a1a1a1a1-b1b1-c1c1-d1d1-00002222aabb:5-9 |
| 138 |
--let $assert_text = Applier retrieved GTID set is logged. |
| 139 |
--source include/assert_grep.inc |
| 140 |
|
| 141 |
|
| 142 |
--echo |
| 143 |
--echo # 6. Start GR on M1 and M2. |
| 144 |
--echo # Switch to single primary mode and assert message is displayed. |
| 145 |
--echo |
| 146 |
|
| 147 |
--let $rpl_connection_name= server1 |
| 148 |
--source include/rpl_connection.inc |
| 149 |
|
| 150 |
--source include/start_group_replication.inc |
| 151 |
|
| 152 |
--let $rpl_connection_name= server2 |
| 153 |
--source include/rpl_connection.inc |
| 154 |
|
| 155 |
--source include/stop_group_replication.inc |
| 156 |
--source include/start_group_replication.inc |
| 157 |
|
| 158 |
--let $rpl_connection_name= server3 |
| 159 |
--source include/rpl_connection.inc |
| 160 |
|
| 161 |
SELECT group_replication_switch_to_multi_primary_mode(); |
| 162 |
|
| 163 |
DROP table t1; |
| 164 |
--source include/rpl_sync.inc |
| 165 |
|
| 166 |
--replace_result $member2_uuid MEMBER2_UUID |
| 167 |
--eval SELECT group_replication_switch_to_single_primary_mode("$member2_uuid") |
| 168 |
|
| 169 |
## ASSERTS |
| 170 |
--let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.2.err |
| 171 |
--let $assert_count = 1 |
| 172 |
--let $assert_select = Elected primary member gtid_executed: a1a1a1a1-b1b1-c1c1-d1d1-00002222aabb:1-12 |
| 173 |
--let $assert_text = Server executed GTID set is logged. |
| 174 |
--source include/assert_grep.inc |
| 175 |
|
| 176 |
--let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.2.err |
| 177 |
--let $assert_count = 1 |
| 178 |
--let $assert_select = Elected primary member applier channel received_transaction_set: a1a1a1a1-b1b1-c1c1-d1d1-00002222aabb:1-9:11-12 |
| 179 |
--let $assert_text = Applier retrieved GTID set is logged. |
| 180 |
--source include/assert_grep.inc |
| 181 |
|
| 182 |
--echo |
| 183 |
--echo # 7. Cleanup. |
| 184 |
--echo |
| 185 |
|
| 186 |
--let $rpl_connection_name= server2 |
| 187 |
--source include/rpl_connection.inc |
| 188 |
|
| 189 |
SET SESSION sql_log_bin= 0; |
| 190 |
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."); |
| 191 |
call mtr.add_suppression("The server was automatically set into read only mode after an error was detected."); |
| 192 |
call mtr.add_suppression("Skipping leave operation: concurrent attempt to leave the group is on-going."); |
| 193 |
SET SESSION sql_log_bin= 1; |
| 194 |
SET GLOBAL group_replication_member_weight= @member_weight2_save; |
| 195 |
|
| 196 |
--let $rpl_group_replication_reset_persistent_vars=1 |
| 197 |
--source include/group_replication_end.inc |