polardbxengine/mysql-test/suite/group_replication/t/gr_autostart_on_install.test

136 lines
4.5 KiB
Plaintext

################################################################################
# This test validates that no issue exists when a member auto joins an existing
# group during installation.
#
# To test this:
# 0) The test requires two servers: M1 and M2.
# 1) Bootstrap group replication on member 1.
# 2) Restart server 2 with start_on_boot=1 (to enable it for the install)
# Stop group replication and reset the applier channel.
# 3) Insert some data on server 1 and stop the applier to block recovery on
# server 2.
# 4) Uninstall and Install the plugin on member 2 (auto start enabled on 2)
# 5) Verify that no transaction can be executed while server 2 recovers.
# 6) Check all is fine after unblocking recovery.
# 7) Clean up.
################################################################################
--source include/big_test.inc
--let $group_replication_group_name= ce94c230-2fc0-11e5-a2cb-0800200c9a66
--source include/have_group_replication_plugin.inc
--source include/force_restart.inc
--let $rpl_skip_group_replication_start= 1
--source include/group_replication.inc
--echo #
--echo # Bootstrap group with server 1.
--echo #
--connection server1
--source include/start_and_bootstrap_group_replication.inc
--echo #
--echo # Restart group replication on server 2
--echo # with group_replication_start_on_boot=1
--echo #
--connection server2
--let $allow_rpl_inited= 1
--let $_group_replication_local_address= `SELECT @@GLOBAL.group_replication_local_address`
--let $_group_replication_group_seeds= `SELECT @@GLOBAL.group_replication_group_seeds`
--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
--replace_result $_group_replication_local_address GROUP_REPLICATION_LOCAL_ADDRESS $_group_replication_group_seeds GROUP_REPLICATION_GROUP_SEEDS
--source include/restart_mysqld.inc
# Needed as we are not using rpl_restart_server.inc
--let $rpl_server_number= 2
--source include/rpl_reconnect.inc
--let $_init_server2_auto_increment= `SELECT @@GLOBAL.AUTO_INCREMENT_INCREMENT`
--let $_init_server2_auto_offset= `SELECT @@GLOBAL.AUTO_INCREMENT_OFFSET`
--let $group_replication_member_state= ONLINE
--source include/gr_wait_for_member_state.inc
--source include/stop_group_replication.inc
# A RESET MASTER was executed in the context of include/master-slave.inc after
# the server auto started group replication.
# The server applier logs will be reset to avoid recovery problems.
RESET SLAVE ALL FOR CHANNEL "group_replication_applier";
--echo #
--echo # Add some data to server 1.
--echo #
--connection server1
CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
--source include/gr_stop_applier_sql_thread.inc
--echo #
--echo # On server 2 uninstall and install the plugin with auto start.
--echo # The plugin should start automatically and recover the missing data
--echo #
--connection server2
--source include/uninstall_group_replication_plugin.inc
--source include/install_group_replication_plugin.inc
--echo #
--echo # On server 2 after restart, recovery should be stuck
--echo # Query execution is not allowed
--echo #
--let $group_replication_member_state= RECOVERING
--source include/gr_wait_for_member_state.inc
--let $wait_condition= SELECT COUNT(*)=1 FROM information_schema.tables WHERE table_name = 't1'
--source include/wait_condition.inc
# install plugin return before set super_read_only, wait to confirm change
--let $wait_condition= SELECT @@GLOBAL.super_read_only = '1'
--source include/wait_condition.inc
--error ER_OPTION_PREVENTS_STATEMENT
INSERT INTO t1 VALUES (2);
--echo #
--echo # After unblocking recovery all should be fine
--echo #
--connection server1
--source include/gr_start_applier_sql_thread.inc
--connection server2
--let $group_replication_member_state= ONLINE
--source include/gr_wait_for_member_state.inc
# The data should be there.
--let $wait_condition= SELECT COUNT(*) = 1 FROM t1;
--source include/wait_condition.inc
--echo #
--echo # Clean up
--echo #
DROP TABLE t1;
--source include/rpl_sync.inc
#Stop group replication and set the auto_increment values recorded on start
--source include/stop_group_replication.inc
# reset auto_increment variables from initial saved values in
# store_group_replication_auto_increment.inc
--let $rpl_server_number=2
--source include/restore_group_replication_auto_increment.inc
--source include/group_replication_end.inc