1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
|
################################################################################
# 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
|