| 1 |
################################################################################ |
| 2 |
# Validate Group Replication can be started and stopped when autocommit is |
| 3 |
# disabled and super_read_only is enabled. |
| 4 |
# |
| 5 |
# Test: |
| 6 |
# 0. This test requires 1 server: |
| 7 |
# server1: group member |
| 8 |
# 1. Create a table on server 1 without generating GTID to |
| 9 |
# avoid confusion on the test asserts. |
| 10 |
# 2. Deploy a group on server1 with autocommit disabled and |
| 11 |
# super_read_only is enabled. |
| 12 |
# 3. Assert that a View_change_log_event was logged. |
| 13 |
# 4. Stop Group Replication on server1 with autocommit disabled |
| 14 |
# and super_read_only is enabled. |
| 15 |
# 5. Assert that no transaction was logged due to |
| 16 |
# STOP GROUP_REPLICATION; |
| 17 |
# 6. Assert that no transaction was logged due to |
| 18 |
# STOP GROUP_REPLICATION and that a statement cannot be |
| 19 |
# be executed between STOP GROUP_REPLICATION and COMMIT |
| 20 |
# when autocommit is disabled. |
| 21 |
# 7. Clean up. |
| 22 |
############################################################################### |
| 23 |
--source include/have_group_replication_plugin.inc |
| 24 |
--let $rpl_skip_group_replication_start= 1 |
| 25 |
--source include/group_replication.inc |
| 26 |
|
| 27 |
|
| 28 |
--echo |
| 29 |
--echo ############################################################ |
| 30 |
--echo # 1. Create a table on server 1 without generating GTID to |
| 31 |
--echo # avoid confusion on the test asserts. |
| 32 |
--let $rpl_connection_name= server1 |
| 33 |
--source include/rpl_connection.inc |
| 34 |
SET SESSION sql_log_bin = 0; |
| 35 |
CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY); |
| 36 |
SET SESSION sql_log_bin = 1; |
| 37 |
|
| 38 |
|
| 39 |
--echo |
| 40 |
--echo ############################################################ |
| 41 |
--echo # 2. Deploy a group on server1 with autocommit disabled and |
| 42 |
--echo # super_read_only is enabled. |
| 43 |
--let $rpl_connection_name= server1 |
| 44 |
--source include/rpl_connection.inc |
| 45 |
--replace_result $group_replication_group_name GROUP_REPLICATION_GROUP_NAME |
| 46 |
--eval SET GLOBAL group_replication_group_name= "$group_replication_group_name" |
| 47 |
--source include/gr_set_bootstrap_group.inc |
| 48 |
|
| 49 |
SET @@GLOBAL.super_read_only= 1; |
| 50 |
SET @saved_autocommit = @@SESSION.autocommit; |
| 51 |
SET @@SESSION.autocommit = 0; |
| 52 |
|
| 53 |
START GROUP_REPLICATION; |
| 54 |
COMMIT; |
| 55 |
|
| 56 |
|
| 57 |
--echo |
| 58 |
--echo ############################################################ |
| 59 |
--echo # 3. Assert that a View_change_log_event was logged. |
| 60 |
--let $rpl_connection_name= server1 |
| 61 |
--source include/rpl_connection.inc |
| 62 |
--let $group_replication_member_state = ONLINE |
| 63 |
--source include/gr_wait_for_member_state.inc |
| 64 |
|
| 65 |
--source include/gr_clear_bootstrap_group.inc |
| 66 |
|
| 67 |
--let $expected_gtid_set= "$group_replication_group_name:1" |
| 68 |
--let $assert_text= START GROUP_REPLICATION did generate a GTID |
| 69 |
--let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = $expected_gtid_set |
| 70 |
--source include/assert.inc |
| 71 |
|
| 72 |
--let $vcle_seq= Gtid # Query/BEGIN # View_change # Query/COMMIT |
| 73 |
# View change (s1 bootstrap) |
| 74 |
--let $event_sequence= $vcle_seq |
| 75 |
--source include/assert_binlog_events.inc |
| 76 |
|
| 77 |
|
| 78 |
--echo |
| 79 |
--echo ############################################################ |
| 80 |
--echo # 4. Stop Group Replication on server1 with autocommit disabled |
| 81 |
--echo # and super_read_only is enabled. |
| 82 |
--let $rpl_connection_name= server1 |
| 83 |
--source include/rpl_connection.inc |
| 84 |
SET @@GLOBAL.super_read_only= 1; |
| 85 |
SET @@SESSION.autocommit = 0; |
| 86 |
|
| 87 |
STOP GROUP_REPLICATION; |
| 88 |
COMMIT; |
| 89 |
|
| 90 |
|
| 91 |
--echo |
| 92 |
--echo ############################################################ |
| 93 |
--echo # 5. Assert that no transaction was logged due to |
| 94 |
--echo # STOP GROUP_REPLICATION; |
| 95 |
--let $rpl_connection_name= server1 |
| 96 |
--source include/rpl_connection.inc |
| 97 |
--let $group_replication_member_state = OFFLINE |
| 98 |
--source include/gr_wait_for_member_state.inc |
| 99 |
|
| 100 |
--let $expected_gtid_set= "$group_replication_group_name:1" |
| 101 |
--let $assert_text= STOP GROUP_REPLICATION did not generate a GTID |
| 102 |
--let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = $expected_gtid_set |
| 103 |
--source include/assert.inc |
| 104 |
|
| 105 |
--let $vcle_seq= Gtid # Query/BEGIN # View_change # Query/COMMIT |
| 106 |
# View change (s1 bootstrap) |
| 107 |
--let $event_sequence= $vcle_seq |
| 108 |
--source include/assert_binlog_events.inc |
| 109 |
|
| 110 |
|
| 111 |
--echo |
| 112 |
--echo ############################################################ |
| 113 |
--echo # 6. Assert that no transaction was logged due to |
| 114 |
--echo # STOP GROUP_REPLICATION and that a statement cannot be |
| 115 |
--echo # be executed between STOP GROUP_REPLICATION and COMMIT |
| 116 |
--echo # when autocommit is disabled. |
| 117 |
--let $rpl_connection_name= server1 |
| 118 |
--source include/rpl_connection.inc |
| 119 |
--source include/start_and_bootstrap_group_replication.inc |
| 120 |
|
| 121 |
--let $expected_gtid_set= "$group_replication_group_name:1-2" |
| 122 |
--let $assert_text= START GROUP_REPLICATION did generate a GTID |
| 123 |
--let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = $expected_gtid_set |
| 124 |
--source include/assert.inc |
| 125 |
|
| 126 |
--let $vcle_seq= Gtid # Query/BEGIN # View_change # Query/COMMIT |
| 127 |
# View change (s1 bootstrap), View change (s1 bootstrap) |
| 128 |
--let $event_sequence= $vcle_seq # $vcle_seq |
| 129 |
--source include/assert_binlog_events.inc |
| 130 |
|
| 131 |
SET @@GLOBAL.read_only= 0; |
| 132 |
SET @@SESSION.autocommit = 0; |
| 133 |
|
| 134 |
STOP GROUP_REPLICATION; |
| 135 |
--error ER_OPTION_PREVENTS_STATEMENT |
| 136 |
INSERT INTO t1 VALUES (1); |
| 137 |
COMMIT; |
| 138 |
|
| 139 |
--let $expected_gtid_set= "$group_replication_group_name:1-2" |
| 140 |
--let $assert_text= STOP GROUP_REPLICATION did not generate a GTID |
| 141 |
--let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = $expected_gtid_set |
| 142 |
--source include/assert.inc |
| 143 |
|
| 144 |
--let $vcle_seq= Gtid # Query/BEGIN # View_change # Query/COMMIT |
| 145 |
# View change (s1 bootstrap), View change (s1 bootstrap) |
| 146 |
--let $event_sequence= $vcle_seq # $vcle_seq |
| 147 |
--source include/assert_binlog_events.inc |
| 148 |
|
| 149 |
--let $assert_text= 'Table t1 must be empty' |
| 150 |
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1, count, 1] = 0 |
| 151 |
--source include/assert.inc |
| 152 |
|
| 153 |
|
| 154 |
--echo |
| 155 |
--echo ############################################################ |
| 156 |
--echo # 7. Clean up. |
| 157 |
--let $rpl_connection_name= server1 |
| 158 |
--source include/rpl_connection.inc |
| 159 |
SET @@SESSION.autocommit = @saved_autocommit; |
| 160 |
SET @@GLOBAL.read_only= 0; |
| 161 |
|
| 162 |
SET SESSION sql_log_bin = 0; |
| 163 |
DROP TABLE t1; |
| 164 |
SET SESSION sql_log_bin = 1; |
| 165 |
|
| 166 |
--source include/group_replication_end.inc |