config root man

Current Path : /usr/opt/mysql57/mysql-test/suite/group_replication/t/

FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64
Upload File :
Current File : //usr/opt/mysql57/mysql-test/suite/group_replication/t/gr_recovery_completion_mode.test

################################################################################
# This test evaluates both recovery policies on when a member should become
# online.
#
# Test:
#   0. The test requires two servers.
#
# Phase 1: Recovery only waits for the certification of all cached transactions
#   1. Create 2 tables (t1,t2) on both servers
#   2. Start group replication on server1 with some data inserted on t1
#   3. Lock table t1 on server 2 and start group replication
#      Recovery will get stuck as the member can't execute data on t1
#   4. Lock table t2 on server 2 and insert some data on t2 on server 1
#      Recovery application of cached data is blocked as t2 is locked
#   5. Unlock t1 and recovery first phase will unblock.
#      The member should become online as it does not wait for the application
#      of cached transactions, only its certification.
#   6. Clean up.
#
# Phase 2: Recovery waits for the execution of all executed transactions
#   1. Create 2 tables (t1,t2) on both servers
#   2. Start group replication on server1 with some data inserted on t1
#   3. Lock table t1 on server 2 and start group replication
#      Recovery will get stuck as the member can't execute data on t1
#   4. Lock table t2 on server 2 and insert some data on t2 on server 1
#      Recovery application of cached data is blocked as t2 is locked
#   5. Unlock t1 and recovery first phase will unblock.
#      The member should still be on recovery as the server is waiting for the
#      execution of cached transactions and t2 is locked.
#   6. Unlock t2 and the application of cached transactions will unblock.
#      The member should become online.
#   7. Clean up.
################################################################################

--let $group_replication_group_name= 08033a70-3560-11e5-a2cb-0800200c9a66
--source ../inc/have_group_replication_plugin.inc
--let $rpl_skip_group_replication_start= 1
--source ../inc/group_replication.inc

--echo ######################################################################
--echo # Phase 1:
--echo # Recovery only waits for the certification of all cached transactions
--echo ######################################################################

--echo #
--echo # Create t1 and t2 on both servers
--echo # Start group replication on server 1 after inserting data on t1
--echo #

--connection server1
--echo server1

SET SESSION sql_log_bin=0;
CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
CREATE TABLE t2 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
SET SESSION sql_log_bin=1;

--source ../inc/start_and_bootstrap_group_replication.inc

INSERT INTO t1 VALUES (1);

--connection server2
--echo server2

SET SESSION sql_log_bin=0;
CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
CREATE TABLE t2 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
SET SESSION sql_log_bin=1;

--echo #
--echo # Lock table t1 and table t2 on server 2
--echo # Table t1: Blocks first phase of recovery
--echo # Table t2: Blocks second phase of recovery
--echo #

SET @configured_rec_policy= @@GLOBAL.group_replication_recovery_complete_at;
SET GLOBAL group_replication_recovery_complete_at= "transactions_certified";

--connection server_2
--echo server_2 (server2)
LOCK TABLE t1 READ;

--connection slave
--echo slave (server2)
LOCK TABLE t2 READ;

--echo #
--echo # Start group replication on server 2 and check it is stuck on recovery
--echo #

--connection server2
--echo server2

--let $group_replication_start_member_state= RECOVERING
--source include/start_group_replication.inc

--echo #
--echo # Insert some transaction on server 1 that will be cached on server 2
--echo #

--connection server1
--echo server1

# Wait for the View Change event to reach the binlog.
--eval SELECT WAIT_FOR_EXECUTED_GTID_SET('$group_replication_group_name:3')
INSERT INTO t2 VALUES (1);

--echo #
--echo # UnLock table t1: First phase of recovery can carry on.
--echo # Member 1 is online as it only waits for certification of cached data
--echo #

--connection server_2
--echo server_2 (server2)

UNLOCK TABLES;

--connection server2
--echo server2

--let $group_replication_member_state= ONLINE
--source ../inc/gr_wait_for_member_state.inc

--echo #
--echo # UnLock table t2: Second phase of recovery can carry on.
--echo # The data should be there.
--echo #

--connection slave
--echo slave (server2)

UNLOCK TABLES;

--let $wait_condition= SELECT COUNT(*)=1 FROM t2;
--source include/wait_condition.inc

--echo #
--echo # Phase 1 cleanup
--echo # Remove the data from the tables and stop group replication on server 2
--echo #

--connection server1
--echo server1

TRUNCATE TABLE t1;
TRUNCATE TABLE t2;

--source include/rpl_sync.inc

--connection server2
--echo server2

--source include/stop_group_replication.inc

--echo ######################################################################
--echo # Phase 2:
--echo # Recovery waits for the execution of all executed transactions
--echo ######################################################################

--echo #
--echo # Start group replication on server 1 after inserting data on t1
--echo #

--connection server1
--echo server1

INSERT INTO t1 VALUES (1);

--echo #
--echo # Change recovery policy on server 2 to wait for transaction execution.
--echo #

--connection server2
--echo server2

SET GLOBAL group_replication_recovery_complete_at= "transactions_applied";

--echo #
--echo # Lock table t1 and table t2 on server 2
--echo # Table t1: Blocks first phase of recovery
--echo # Table t2: Blocks second phase of recovery
--echo #

--connection server_2
--echo server_2 (server2)

LOCK TABLE t1 READ;

--connection slave
--echo slave (server2)

LOCK TABLE t2 READ;

--echo #
--echo # Start group replication on server 2 and check it is stuck on recovery
--echo #

--connection server2
--echo server2

--let $group_replication_start_member_state= RECOVERING
--source include/start_group_replication.inc

--echo #
--echo # Insert some transaction on server 1 that will be cached on server 2
--echo #

--connection server1
--echo server1

INSERT INTO t2 VALUES (1);

--echo #
--echo # Wait for the transactions to be cached on server 2
--echo #

--connection server2
--echo server2

--let $wait_condition= SELECT COUNT_TRANSACTIONS_IN_QUEUE=2 FROM performance_schema.replication_group_member_stats;
--source include/wait_condition.inc

--echo #
--echo # UnLock table t1: First phase of recovery can carry on.
--echo # Member 2 is still recovering as it can't apply cached data
--echo #

--connection server_2
--echo server_2 (server2)

UNLOCK TABLES;

--connection server2
--echo server2

--let $server2_uuid= `SELECT @@GLOBAL.SERVER_UUID`
--let $member_state= query_get_value(SELECT Member_State from performance_schema.replication_group_members WHERE member_id= '$server2_uuid', Member_State, 1)
--let $assert_text= The value of member_state should be recovering
--let $assert_cond= "$member_state" = "RECOVERING"
--source include/assert.inc

--echo #
--echo # UnLock table t2: Second phase of recovery can carry on.
--echo # The data should be there and the member should now be online.
--echo #

--connection slave
--echo slave (server2)

UNLOCK TABLES;

--let $wait_condition= SELECT COUNT(*)=1 FROM t2;
--source include/wait_condition.inc

--let $group_replication_member_state= ONLINE
--source ../inc/gr_wait_for_member_state.inc

--echo #
--echo # Test cleanup
--echo #

--connection server2
--echo server2

DROP TABLE t1;
DROP TABLE t2;

SET GLOBAL group_replication_recovery_complete_at= @configured_rec_policy;

--source ../inc/group_replication_end.inc

Man Man