← Back
Editing: gr_replicate_server_to_group_conflict.test
################################################################################ # WL#6833: GCS Replication: Read-set free Certification # Module (DBSM Snapshot Isolation) # # Scenario 5: Replicate from a server into a group with # conflicts detected from server to group. # # T1: WS={t1.c1=0, t1.c1=3} # T2: WS={t1.c1=1, t1.c1=2} # # Outcome: T1 must abort, T2 must commit. # # Verify Group Replication behaviour when we establish a # asynchronous replication connection from a server to a group # and that connection is present to conflicts. # # Test: # 0. The test requires three servers: M1, M2 and M3. # 1. Setup GR on two servers (M1 and M2). # 2. Setup asynchronous replication connection from M3 into group(M1) # i.e. M3 -> M1. # 3. Execute some transactions on M3. # 4. Wait until transactions executed on M3 are applied on group. # 5. Make M1 block before message broadcast to group, using DEBUG point. Then, # commit a transaction (T1) on M3 that won't replicate to group due to # conflicts with T1. # 6. Wait until M1 SQL thread from M3 reaches the debug sync point. # 7. Commit a transaction (T2) on group on M2. # 8. Resume message broadcast to group on M1. Check that conflict was detected # on asynchronous replication connection. Expect ER3101 on M1. # 9. Force conflicting transaction on group, by committing a empty transaction # with the same GTID. No data merge is done. Commit a new transaction on M3 # to assert that asynchronous replication is working properly. # 10. Wait until transactions executed on M3 are applied on group. # 11. Validate data on M3. # 12. Validate data on M1. GTID_EXECUTED on M1 must have GTID_EXECUTED from M3. # 13. Validate data on M2. GTID_EXECUTED on M2 must have GTID_EXECUTED from M3. # 14. Clean data. # 15. Stop asynchronous replication connection from M3 into group(M1). # 16. Stop Group Replication on M1 and M2. # 17. Uninstall GTID utils. ################################################################################ --source include/have_debug.inc --source include/have_debug_sync.inc --let $group_replication_group_name= 8a94f357-aab4-11df-86ab-c80aa9420004 --source ../inc/have_group_replication_plugin.inc --let $rpl_skip_group_replication_start= 1 --let $rpl_server_count= 3 --source ../inc/group_replication.inc # Keep binary logs with only GTIDs from test. --connection server1 SET SESSION sql_log_bin= 0; --source include/gtid_utils.inc SET SESSION sql_log_bin= 1; --connection server2 SET SESSION sql_log_bin= 0; --source include/gtid_utils.inc SET SESSION sql_log_bin= 1; --connection server3 SET SESSION sql_log_bin= 0; --source include/gtid_utils.inc SET SESSION sql_log_bin= 1; --echo --echo ############################################################ --echo # 1. Setup Group Replication on server 1 and 2. --connection server1 --source ../inc/start_and_bootstrap_group_replication.inc --connection server2 --source include/start_group_replication.inc --let $group_replication_number_of_members= 2 --source ../inc/gr_wait_for_number_of_members.inc --echo --echo ############################################################ --echo # 2. Setup a asynchronous replication connection from server 3 --echo # into group (server 1) --connection server1 --replace_result $SERVER_MYPORT_3 SERVER_3_PORT --eval CHANGE MASTER TO MASTER_HOST="127.0.0.1", MASTER_USER="root", MASTER_PASSWORD="", MASTER_PORT=$SERVER_MYPORT_3, MASTER_AUTO_POSITION=1 FOR CHANNEL "" --source include/start_slave.inc --echo --echo ############################################################ --echo # 3. Execute some transactions on server 3. --connection server3 --eval SET GTID_NEXT= '$uuida:1' CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB; SET GTID_NEXT= 'AUTOMATIC'; --eval SET GTID_NEXT= '$uuida:2' INSERT INTO t1 VALUES (0); SET GTID_NEXT= 'AUTOMATIC'; --echo --echo ############################################################ --echo # 4. Wait until transactions executed on server 3 are --echo # applied on group. --connection server3 --let $sync_slave_connection= server1 --source include/sync_slave_sql_with_master.inc --connection server3 --let $sync_slave_connection= server2 --source include/sync_slave_sql_with_master.inc --echo --echo ############################################################ --echo # 5. Commit a transaction (T1) on server 3 that won't --echo # replicate to group due to conflicts with T1. --echo # Before that make server 1 block before message --echo # broadcast to group. --connection server1 --source include/stop_slave.inc SET @server1_debug_save= @@GLOBAL.DEBUG; SET @@GLOBAL.DEBUG= '+d,debug.wait_after_set_snapshot_version_on_transaction_context_log_event'; --source include/start_slave.inc --connection server3 --eval SET GTID_NEXT= '$uuida:3' UPDATE t1 SET c1=3 WHERE c1=0; SET GTID_NEXT= 'AUTOMATIC'; --echo --echo ############################################################ --echo # 6. Wait until server 1 SQL thread from server 3 reaches --echo # the debug sync point: --echo # wait_after_set_snapshot_version_on_transaction_context_log_event --let $rpl_connection_name= server1 --source include/rpl_connection.inc --let $wait_condition=SELECT COUNT(*)=1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE State = 'debug sync point: now' --source include/wait_condition.inc --echo --echo ############################################################ --echo # 7. Commit a transaction (T2) on group on server 2. --connection server2 UPDATE t1 SET c1=2 WHERE c1=0; --echo --echo ############################################################ --echo # 8. Resume message broadcast to group on server 1. --echo # Check that conflict was detected on asynchronous --echo # replication connection. --connection server1 SET @@GLOBAL.DEBUG= @debug_saved; SET DEBUG_SYNC= 'now SIGNAL signal.resume_after_set_snapshot_version_on_transaction_context_log_event'; --connection server2 --let $sync_slave_connection= server1 --source include/sync_slave_sql_with_master.inc --let $slave_sql_errno= convert_error(ER_TRANSACTION_ROLLBACK_DURING_COMMIT) --source include/wait_for_slave_sql_error.inc SET DEBUG_SYNC= 'RESET'; SET SESSION sql_log_bin= 0; call mtr.add_suppression("Slave SQL for channel '': Error in Xid_log_event: Commit could not be completed, 'Plugin instructed the server to rollback the current transaction.', Error_code:.*"); call mtr.add_suppression("Slave: Plugin instructed the server to rollback the current transaction. Error_code:.*"); call mtr.add_suppression("Slave SQL for channel '': Worker.* failed executing transaction"); call mtr.add_suppression(".*The slave coordinator and worker threads are stopped.*. Error_code: 1756"); SET SESSION sql_log_bin= 1; --echo --echo ############################################################ --echo # 9. Force conflicting transaction on group, by committing --echo # a empty transaction with the same GTID. No data merge --echo # is done. --echo # Commit a new transaction on server 3 to assert that --echo # asynchronous replication is working properly. --connection server1 --eval SET GTID_NEXT= '$uuida:3' BEGIN; COMMIT; SET GTID_NEXT= 'AUTOMATIC'; --source include/rpl_sync.inc --source include/start_slave_sql.inc --connection server3 --eval SET GTID_NEXT= '$uuida:4' INSERT INTO t1 VALUES (4); SET GTID_NEXT= 'AUTOMATIC'; --echo --echo ############################################################ --echo # 10. Wait until transactions executed on server 3 are --echo # applied on group. --connection server3 --let $sync_slave_connection= server1 --source include/sync_slave_sql_with_master.inc --connection server3 --let $sync_slave_connection= server2 --source include/sync_slave_sql_with_master.inc --echo --echo ############################################################ --echo # 11. Validate data on server 3. --connection server3 --let $assert_text= GTID_EXECUTED must contain all committed GTIDs --let $assert_cond= GTID_IS_EQUAL(@@GLOBAL.GTID_EXECUTED, "$uuida:1-4") --source include/assert.inc --let $assert_text= 'There is no value 0 in table t1' --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 0, count, 1] = 0 --source include/assert.inc --let $assert_text= 'There is no value 2 in table t1' --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 2, count, 1] = 0 --source include/assert.inc --let $assert_text= 'There is a value 3 in table t1' --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 3, count, 1] = 1 --source include/assert.inc --let $assert_text= 'There is a value 4 in table t1' --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 4, count, 1] = 1 --source include/assert.inc --echo --echo ############################################################ --echo # 12. GTID_EXECUTED on server 1 must contain GTID_EXECUTED --echo # from server 3. --echo # Validate data on server 1. --connection server1 --let $group_expected_gtid_set= "8a94f357-aab4-11df-86ab-c80aa9420004:1-3,$uuida:1-4" --let $assert_text= GTID_EXECUTED must contain server 3 GTID_EXECUTED --let $assert_cond= GTID_IS_EQUAL(@@GLOBAL.GTID_EXECUTED, $group_expected_gtid_set) --source include/assert.inc --let $assert_text= 'There is no value 0 in table t1' --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 0, count, 1] = 0 --source include/assert.inc --let $assert_text= 'There is a value 2 in table t1' --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 2, count, 1] = 1 --source include/assert.inc --let $assert_text= 'There is no value 3 in table t1' --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 3, count, 1] = 0 --source include/assert.inc --let $assert_text= 'There is a value 4 in table t1' --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 4, count, 1] = 1 --source include/assert.inc --echo --echo ############################################################ --echo # 13. GTID_EXECUTED on server 2 must contain GTID_EXECUTED --echo # from server 3. --echo # Validate data on server 2. --connection server2 --let $assert_text= GTID_EXECUTED must contain server 3 GTID_EXECUTED --let $assert_cond= GTID_IS_EQUAL(@@GLOBAL.GTID_EXECUTED, $group_expected_gtid_set) --source include/assert.inc --let $assert_text= 'There is no value 0 in table t1' --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 0, count, 1] = 0 --source include/assert.inc --let $assert_text= 'There is a value 2 in table t1' --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 2, count, 1] = 1 --source include/assert.inc --let $assert_text= 'There is no value 3 in table t1' --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 3, count, 1] = 0 --source include/assert.inc --let $assert_text= 'There is a value 4 in table t1' --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 4, count, 1] = 1 --source include/assert.inc --echo --echo ############################################################ --echo # 14. Clean data. --connection server3 DROP TABLE t1; --let $sync_slave_connection= server1 --source include/sync_slave_sql_with_master.inc --connection server3 --let $sync_slave_connection= server2 --source include/sync_slave_sql_with_master.inc --echo --echo ############################################################ --echo # 15. Stop asynchronous replication connection from server 3 --echo # into group (server 1) --connection server1 --source include/stop_slave.inc CHANGE MASTER TO MASTER_AUTO_POSITION=0 FOR CHANNEL ""; --echo --echo ############################################################ --echo # 16. Stop Group Replication on server 1 and 2. --connection server1 --source include/stop_group_replication.inc --connection server2 --source include/stop_group_replication.inc --echo --echo ############################################################ --echo # 17. Uninstall GTID utils. --connection server1 SET SESSION sql_log_bin= 0; --source include/gtid_utils_end.inc SET SESSION sql_log_bin= 1; --connection server2 SET SESSION sql_log_bin= 0; --source include/gtid_utils_end.inc SET SESSION sql_log_bin= 1; --connection server3 SET SESSION sql_log_bin= 0; --source include/gtid_utils_end.inc SET SESSION sql_log_bin= 1; --source ../inc/group_replication_end.inc
Save File
Cancel