################################################################################ # Test that evaluates the safe guards that stop members from joining with # transactions not present in the group. # # Here we test several cases where the joiner is allowed or not in the group # based on its executed transaction set. # # Test guide: # 0. The test requires three servers. # Test case 1: A member that has an unrelated transaction fails to join # 1) There is a group with a member that has some transactions # 2) Insert a transaction on server 2 that acquires a local GTID # 3) Server 2 fails to join because the group doesn't know that GTID # # Test case 2: A member that has more group transactions fails to join # 1) Take server 1 out of the group. # 2) Clean server 2 and boot the group again with it # 3) Try to add server 1 to the group. It fails because server 1 has 5 # transaction and server 2 only has 1 # # 3. Verify all is fine. # # 4. Clean up. ################################################################################ --source include/big_test.inc --let $group_replication_group_name= b2b6cdc0-eb94-11e5-a837-0800200c9a66 --source include/have_group_replication_plugin.inc --let $rpl_gtid_utils= 1 --let $rpl_skip_group_replication_start= 1 --source include/group_replication.inc --let $errand_transaction_uuid= aaaaaaaa-bbbb-aaaa-bbbb-aaaaaaaaaaaa # Suppress errors --let $rpl_connection_name= server1 --source include/rpl_connection.inc SET SESSION sql_log_bin= 0; call mtr.add_suppression(".*This member has more executed transactions *.*"); call mtr.add_suppression(".*The member contains transactions not present *.*"); SET SESSION sql_log_bin= 1; --let $rpl_connection_name= server2 --source include/rpl_connection.inc SET SESSION sql_log_bin= 0; call mtr.add_suppression(".*This member has more executed transactions *.*"); call mtr.add_suppression(".*The member contains transactions not present *.*"); SET SESSION sql_log_bin= 1; --echo # --echo # Setup the first member --echo # --let $rpl_connection_name= server1 --source include/rpl_connection.inc --source include/start_and_bootstrap_group_replication.inc # Add some data for recovery CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB; INSERT INTO t1 VALUES (1); --let $assert_text= The first member has 3 transaction belonging to the group --let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$group_replication_group_name:1-3"; --source include/assert.inc --echo # --echo # Test case 1: Try to add a member with local data on it. --echo # The start group replication command shall fail --echo # --let $rpl_connection_name= server2 --source include/rpl_connection.inc --eval SET GTID_NEXT= "$errand_transaction_uuid:1" CREATE TABLE t2 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB; SET GTID_NEXT= "AUTOMATIC"; --let $assert_text= The member shall contain a local transaction --let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$errand_transaction_uuid:1"; --source include/assert.inc --eval SET GLOBAL group_replication_group_name= "$group_replication_group_name" --error ER_GROUP_REPLICATION_CONFIGURATION START GROUP_REPLICATION; --echo # Test case 1 cleanup --echo # Remove data on server 2 DROP TABLE t2; RESET MASTER; #For precaution, wait for server 2 to leave --let $rpl_connection_name= server1 --source include/rpl_connection.inc --let $group_replication_number_of_members= 1 --source include/gr_wait_for_number_of_members.inc # Wait until View_change_log_event from server 2 join is logged on binary log --let $wait_condition= SELECT @@GLOBAL.GTID_EXECUTED = "$group_replication_group_name:1-4" --source include/wait_condition.inc --echo # --echo # Test case 2: Try to add a member with more group transactions --echo # The start group replication command shall fail --echo # --let $rpl_connection_name= server1 --source include/rpl_connection.inc --source include/stop_group_replication.inc --let $rpl_connection_name= server2 --source include/rpl_connection.inc --source include/start_and_bootstrap_group_replication.inc --let $assert_text= The first member to join has only one transaction --let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$group_replication_group_name:1"; --source include/assert.inc --let $rpl_connection_name= server1 --source include/rpl_connection.inc --let $assert_text= The second member to join has 4 transactions --let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$group_replication_group_name:1-4"; --source include/assert.inc --eval SET GLOBAL group_replication_group_name= "$group_replication_group_name" --error ER_GROUP_REPLICATION_CONFIGURATION START GROUP_REPLICATION; --echo # Test case 2 cleanup --echo # Put server 1 back in the group --let $rpl_connection_name= server2 --source include/rpl_connection.inc #For precaution, wait for server 1 to leave --let $group_replication_number_of_members= 1 --source include/gr_wait_for_number_of_members.inc --source include/stop_group_replication.inc RESET MASTER; --let $rpl_connection_name= server1 --source include/rpl_connection.inc --source include/start_and_bootstrap_group_replication.inc --let $rpl_connection_name= server2 --source include/rpl_connection.inc --source include/start_group_replication.inc --echo # --echo # Verify all is fine --echo # --let $rpl_connection_name= server1 --source include/rpl_connection.inc INSERT INTO t1 VALUES (2); --source include/rpl_sync.inc --let $assert_text= 'There are two values in table t1' --let $assert_cond= [SELECT COUNT(*) AS count FROM t1, count, 1] = 2 --source include/assert.inc --let $rpl_connection_name= server2 --source include/rpl_connection.inc --let $assert_text= 'There are two values in table t1' --let $assert_cond= [SELECT COUNT(*) AS count FROM t1, count, 1] = 2 --source include/assert.inc --echo # --echo # Cleaning up --echo # DROP TABLE t1; --source include/group_replication_end.inc