| 1 |
################################################################################ |
| 2 |
# This test proves that the plugin will leave the group when it cannot enable |
| 3 |
# the read mode in the server. |
| 4 |
# |
| 5 |
# Test: |
| 6 |
# 0) The test requires two servers. |
| 7 |
# 1) Bootstrap group with server 1. |
| 8 |
# 2) Restart server 2 with start_on_boot=1 (to enable it for the install). |
| 9 |
# 3) Insert some data on server 1. |
| 10 |
# 4) Uninstall and Install the plugin on member 2 (auto start enabled on 2) |
| 11 |
# Use a debug point to make the read mode fail when connecting. |
| 12 |
# 5) Verify that server 2 goes to ERROR state. Check that we cannot execute |
| 13 |
# transactions. |
| 14 |
# 6) Check all is fine after restarting group replication on server 2. |
| 15 |
# 7) Clean up. |
| 16 |
################################################################################ |
| 17 |
|
| 18 |
--source include/big_test.inc |
| 19 |
--source include/have_debug.inc |
| 20 |
--let $group_replication_group_name= 7768a190-a421-11e5-a837-0800200c9a66 |
| 21 |
--source include/have_group_replication_plugin.inc |
| 22 |
--source include/force_restart.inc |
| 23 |
--let $rpl_skip_group_replication_start= 1 |
| 24 |
--source include/group_replication.inc |
| 25 |
|
| 26 |
--echo # |
| 27 |
--echo # Bootstrap group with server 1. |
| 28 |
--echo # |
| 29 |
|
| 30 |
--let $rpl_connection_name= server1 |
| 31 |
--source include/rpl_connection.inc |
| 32 |
--source include/start_and_bootstrap_group_replication.inc |
| 33 |
|
| 34 |
--echo # |
| 35 |
--echo # Restart group replication on server 2 |
| 36 |
--echo # with group_replication_start_on_boot=1 |
| 37 |
--echo # |
| 38 |
|
| 39 |
--let $rpl_connection_name= server2 |
| 40 |
--source include/rpl_connection.inc |
| 41 |
|
| 42 |
set session sql_log_bin=0; |
| 43 |
call mtr.add_suppression("Error when activating super_read_only mode on start. The member will now exit the group."); |
| 44 |
call mtr.add_suppression("Transaction cannot be executed while Group Replication is on ERROR state.*"); |
| 45 |
call mtr.add_suppression("Run function 'before_commit' in plugin 'group_replication' failed*"); |
| 46 |
call mtr.add_suppression("The member is leaving a group without being on one"); |
| 47 |
call mtr.add_suppression("The group replication user is not present in the server. The user will be recreated, please do not remove it"); |
| 48 |
call mtr.add_suppression("Skipping leave operation: concurrent attempt to leave the group is on-going."); |
| 49 |
call mtr.add_suppression("On plugin shutdown it was not possible to enable the server read only mode.*"); |
| 50 |
call mtr.add_suppression("The server was automatically set into offline mode after an error was detected."); |
| 51 |
set session sql_log_bin=1; |
| 52 |
|
| 53 |
SET @debug_save= @@GLOBAL.DEBUG; |
| 54 |
|
| 55 |
--let $allow_rpl_inited= 1 |
| 56 |
--let $_group_replication_local_address= `SELECT @@GLOBAL.group_replication_local_address` |
| 57 |
--let $_group_replication_group_seeds= `SELECT @@GLOBAL.group_replication_group_seeds` |
| 58 |
--let $restart_parameters=restart:--group_replication_local_address=$_group_replication_local_address --group_replication_group_seeds=$_group_replication_group_seeds --group_replication_start_on_boot=1 |
| 59 |
--replace_result $_group_replication_local_address GROUP_REPLICATION_LOCAL_ADDRESS $_group_replication_group_seeds GROUP_REPLICATION_GROUP_SEEDS |
| 60 |
--source include/restart_mysqld.inc |
| 61 |
|
| 62 |
# Needed as we are not using rpl_restart_server.inc |
| 63 |
--let $rpl_server_number= 2 |
| 64 |
--source include/rpl_reconnect.inc |
| 65 |
--let $group_replication_member_state= ONLINE |
| 66 |
--source include/gr_wait_for_member_state.inc |
| 67 |
|
| 68 |
--echo # |
| 69 |
--echo # Add some data to server 1. |
| 70 |
--echo # |
| 71 |
|
| 72 |
--let $rpl_connection_name= server1 |
| 73 |
--source include/rpl_connection.inc |
| 74 |
|
| 75 |
CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB; |
| 76 |
INSERT INTO t1 VALUES (1); |
| 77 |
|
| 78 |
-- source include/rpl_sync.inc |
| 79 |
|
| 80 |
--echo # |
| 81 |
--echo # On server 2 uninstall and install the plugin with auto start. |
| 82 |
--echo # With debug set to group_replication_read_mode_error it should fail. |
| 83 |
--echo # |
| 84 |
|
| 85 |
--let $rpl_connection_name= server2 |
| 86 |
--source include/rpl_connection.inc |
| 87 |
|
| 88 |
--source include/uninstall_group_replication_plugin.inc |
| 89 |
|
| 90 |
SET @@GLOBAL.DEBUG='d,group_replication_read_mode_error'; |
| 91 |
|
| 92 |
--source include/install_group_replication_plugin.inc |
| 93 |
|
| 94 |
--let $group_replication_member_state= ERROR |
| 95 |
--source include/gr_wait_for_member_state.inc |
| 96 |
|
| 97 |
--let $assert_text= P_S table replication_group_members must only contain 1 member |
| 98 |
--let $assert_cond= "[SELECT COUNT(*) FROM performance_schema.replication_group_members]" = 1 |
| 99 |
--source include/assert.inc |
| 100 |
|
| 101 |
--source include/assert_and_disable_offline_mode.inc |
| 102 |
|
| 103 |
--echo # |
| 104 |
--echo # Check that we cannot execute transactions |
| 105 |
--echo # |
| 106 |
|
| 107 |
--error ER_RUN_HOOK_ERROR |
| 108 |
INSERT INTO t1 VALUES (2); |
| 109 |
|
| 110 |
--let $skip_assert_read_only= 1 |
| 111 |
--source include/stop_group_replication.inc |
| 112 |
|
| 113 |
--echo # |
| 114 |
--echo # On server 2 after restarting GR all should be fine. |
| 115 |
--echo # |
| 116 |
|
| 117 |
SET @@GLOBAL.DEBUG= @debug_save; |
| 118 |
--source include/start_group_replication.inc |
| 119 |
|
| 120 |
INSERT INTO t1 VALUES (2); |
| 121 |
|
| 122 |
--let $rpl_connection_name= server1 |
| 123 |
--source include/rpl_connection.inc |
| 124 |
|
| 125 |
# The data should be there. |
| 126 |
--let $wait_condition= SELECT COUNT(*) = 2 FROM t1; |
| 127 |
--source include/wait_condition.inc |
| 128 |
|
| 129 |
--echo # |
| 130 |
--echo # Clean up |
| 131 |
--echo # |
| 132 |
|
| 133 |
DROP TABLE t1; |
| 134 |
|
| 135 |
--source include/group_replication_end.inc |