| 1 |
############################################################################### |
| 2 |
# |
| 3 |
# Error in the election process that prevent its progress shall |
| 4 |
# make the server abort (if configured to) as its configuration may have |
| 5 |
# deviated from the group. |
| 6 |
# |
| 7 |
# Test: |
| 8 |
# 0. This test requires three servers |
| 9 |
# 1. Server1 start, bootstrap the group |
| 10 |
# 2. Start server2 and server3 |
| 11 |
# 3. Fake a stopped applier on server2 |
| 12 |
# 4. Set server2 weight higher to be new primary server |
| 13 |
# 5. Stop primary member that will force election from another member |
| 14 |
# 6. Server2 will fail (applier thread stopped) and abort |
| 15 |
# 7. Server3 is the new primary |
| 16 |
# 8. Wait for server 2 to disconnect/abort and restart |
| 17 |
# 9. Cleanup |
| 18 |
# |
| 19 |
############################################################################### |
| 20 |
|
| 21 |
# Needed as abort_plugin_process() function calls DBUG_SUICIDE() |
| 22 |
--source include/have_debug.inc |
| 23 |
--source include/not_valgrind.inc |
| 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. Server1 start, bootstrap the group |
| 32 |
|
| 33 |
--source include/start_and_bootstrap_group_replication.inc |
| 34 |
|
| 35 |
--echo |
| 36 |
--echo # 2. Start server2 and server3 |
| 37 |
|
| 38 |
--let $rpl_connection_name= server2 |
| 39 |
--source include/rpl_connection.inc |
| 40 |
|
| 41 |
set session sql_log_bin=0; |
| 42 |
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."); |
| 43 |
call mtr.add_suppression("The server was automatically set into read only mode after an error was detected."); |
| 44 |
call mtr.add_suppression("The plugin encountered a critical error and will abort: Fatal error during the primary election process:*"); |
| 45 |
set session sql_log_bin=1; |
| 46 |
|
| 47 |
--source include/start_group_replication.inc |
| 48 |
|
| 49 |
--let $rpl_connection_name= server3 |
| 50 |
--source include/rpl_connection.inc |
| 51 |
--source include/start_group_replication.inc |
| 52 |
|
| 53 |
--let $server3_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1) |
| 54 |
|
| 55 |
--echo |
| 56 |
--echo # 3. Fake a stopped applier on server2 |
| 57 |
|
| 58 |
--let $rpl_connection_name= server2 |
| 59 |
--source include/rpl_connection.inc |
| 60 |
|
| 61 |
SET @@GLOBAL.DEBUG= '+d,group_replication_wait_for_gtid_execution_force_error'; |
| 62 |
|
| 63 |
--echo |
| 64 |
--echo # 4. Set server2 weight higher to be new primary server |
| 65 |
|
| 66 |
SET GLOBAL group_replication_member_weight= 90; |
| 67 |
|
| 68 |
SET @@GLOBAL.group_replication_exit_state_action = ABORT_SERVER; |
| 69 |
|
| 70 |
# Inform MTR that we are expecting an abort and that it should wait before |
| 71 |
# restarting the aborting member |
| 72 |
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.2.expect |
| 73 |
|
| 74 |
--echo |
| 75 |
--echo # 5. Stop primary member that will force election from another member |
| 76 |
|
| 77 |
--let $rpl_connection_name= server1 |
| 78 |
--source include/rpl_connection.inc |
| 79 |
|
| 80 |
--source include/stop_group_replication.inc |
| 81 |
|
| 82 |
--echo |
| 83 |
--echo # 6. Server2 will fail (applier thread stopped) and abort |
| 84 |
|
| 85 |
--let $rpl_connection_name= server3 |
| 86 |
--source include/rpl_connection.inc |
| 87 |
|
| 88 |
--let $group_replication_number_of_members= 1 |
| 89 |
--source include/gr_wait_for_number_of_members.inc |
| 90 |
|
| 91 |
--echo # 7. Server3 is the new primary |
| 92 |
|
| 93 |
--source include/gr_assert_primary_member.inc |
| 94 |
|
| 95 |
--echo |
| 96 |
--echo # 8. Wait for server 2 to disconnect/abort and restart |
| 97 |
|
| 98 |
--let $rpl_connection_name= server2 |
| 99 |
--source include/rpl_connection.inc |
| 100 |
--source include/wait_until_disconnected.inc |
| 101 |
# Inform MTR that it should restart the aborted member |
| 102 |
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.2.expect |
| 103 |
|
| 104 |
--let $rpl_server_number= 2 |
| 105 |
--source include/rpl_reconnect.inc |
| 106 |
SET @@GLOBAL.DEBUG= '-d,group_replication_wait_for_gtid_execution_force_error'; |
| 107 |
|
| 108 |
--echo |
| 109 |
--echo # 9. Cleanup |
| 110 |
|
| 111 |
--let $rpl_group_replication_reset_persistent_vars=1 |
| 112 |
--let $rpl_group_replication_single_primary_mode=1 |
| 113 |
--source include/group_replication_end.inc |