################################################################################ # Validate Group Replication can be started and stopped when autocommit is # disabled and super_read_only is enabled. # # Test: # 0. This test requires 1 server: # server1: group member # 1. Create a table on server 1 without generating GTID to # avoid confusion on the test asserts. # 2. Deploy a group on server1 with autocommit disabled and # super_read_only is enabled. # 3. Assert that a View_change_log_event was logged. # 4. Stop Group Replication on server1 with autocommit disabled # and super_read_only is enabled. # 5. Assert that no transaction was logged due to # STOP GROUP_REPLICATION; # 6. Assert that no transaction was logged due to # STOP GROUP_REPLICATION and that a statement cannot be # be executed between STOP GROUP_REPLICATION and COMMIT # when autocommit is disabled. # 7. Clean up. ############################################################################### --source include/have_group_replication_plugin.inc --let $rpl_skip_group_replication_start= 1 --source include/group_replication.inc --echo --echo ############################################################ --echo # 1. Create a table on server 1 without generating GTID to --echo # avoid confusion on the test asserts. --let $rpl_connection_name= server1 --source include/rpl_connection.inc SET SESSION sql_log_bin = 0; CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY); SET SESSION sql_log_bin = 1; --echo --echo ############################################################ --echo # 2. Deploy a group on server1 with autocommit disabled and --echo # super_read_only is enabled. --let $rpl_connection_name= server1 --source include/rpl_connection.inc --replace_result $group_replication_group_name GROUP_REPLICATION_GROUP_NAME --eval SET GLOBAL group_replication_group_name= "$group_replication_group_name" --source include/gr_set_bootstrap_group.inc SET @@GLOBAL.super_read_only= 1; SET @saved_autocommit = @@SESSION.autocommit; SET @@SESSION.autocommit = 0; START GROUP_REPLICATION; COMMIT; --echo --echo ############################################################ --echo # 3. Assert that a View_change_log_event was logged. --let $rpl_connection_name= server1 --source include/rpl_connection.inc --let $group_replication_member_state = ONLINE --source include/gr_wait_for_member_state.inc --source include/gr_clear_bootstrap_group.inc --let $expected_gtid_set= "$group_replication_group_name:1" --let $assert_text= START GROUP_REPLICATION did generate a GTID --let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = $expected_gtid_set --source include/assert.inc --let $vcle_seq= Gtid # Query/BEGIN # View_change # Query/COMMIT # View change (s1 bootstrap) --let $event_sequence= $vcle_seq --source include/assert_binlog_events.inc --echo --echo ############################################################ --echo # 4. Stop Group Replication on server1 with autocommit disabled --echo # and super_read_only is enabled. --let $rpl_connection_name= server1 --source include/rpl_connection.inc SET @@GLOBAL.super_read_only= 1; SET @@SESSION.autocommit = 0; STOP GROUP_REPLICATION; COMMIT; --echo --echo ############################################################ --echo # 5. Assert that no transaction was logged due to --echo # STOP GROUP_REPLICATION; --let $rpl_connection_name= server1 --source include/rpl_connection.inc --let $group_replication_member_state = OFFLINE --source include/gr_wait_for_member_state.inc --let $expected_gtid_set= "$group_replication_group_name:1" --let $assert_text= STOP GROUP_REPLICATION did not generate a GTID --let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = $expected_gtid_set --source include/assert.inc --let $vcle_seq= Gtid # Query/BEGIN # View_change # Query/COMMIT # View change (s1 bootstrap) --let $event_sequence= $vcle_seq --source include/assert_binlog_events.inc --echo --echo ############################################################ --echo # 6. Assert that no transaction was logged due to --echo # STOP GROUP_REPLICATION and that a statement cannot be --echo # be executed between STOP GROUP_REPLICATION and COMMIT --echo # when autocommit is disabled. --let $rpl_connection_name= server1 --source include/rpl_connection.inc --source include/start_and_bootstrap_group_replication.inc --let $expected_gtid_set= "$group_replication_group_name:1-2" --let $assert_text= START GROUP_REPLICATION did generate a GTID --let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = $expected_gtid_set --source include/assert.inc --let $vcle_seq= Gtid # Query/BEGIN # View_change # Query/COMMIT # View change (s1 bootstrap), View change (s1 bootstrap) --let $event_sequence= $vcle_seq # $vcle_seq --source include/assert_binlog_events.inc SET @@GLOBAL.read_only= 0; SET @@SESSION.autocommit = 0; STOP GROUP_REPLICATION; --error ER_OPTION_PREVENTS_STATEMENT INSERT INTO t1 VALUES (1); COMMIT; --let $expected_gtid_set= "$group_replication_group_name:1-2" --let $assert_text= STOP GROUP_REPLICATION did not generate a GTID --let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = $expected_gtid_set --source include/assert.inc --let $vcle_seq= Gtid # Query/BEGIN # View_change # Query/COMMIT # View change (s1 bootstrap), View change (s1 bootstrap) --let $event_sequence= $vcle_seq # $vcle_seq --source include/assert_binlog_events.inc --let $assert_text= 'Table t1 must be empty' --let $assert_cond= [SELECT COUNT(*) AS count FROM t1, count, 1] = 0 --source include/assert.inc --echo --echo ############################################################ --echo # 7. Clean up. --let $rpl_connection_name= server1 --source include/rpl_connection.inc SET @@SESSION.autocommit = @saved_autocommit; SET @@GLOBAL.read_only= 0; SET SESSION sql_log_bin = 0; DROP TABLE t1; SET SESSION sql_log_bin = 1; --source include/group_replication_end.inc