| 1 |
################################################################################ |
| 2 |
# Validate that a group mode change with ongoing cascading FK |
| 3 |
# transactions does terminate successfully. |
| 4 |
# |
| 5 |
# 1. Bootstrap group on server1, which will be the primary. |
| 6 |
# 2. Add a second member to the group. |
| 7 |
# 3. Start a transaction that has cascading FK on the primary. |
| 8 |
# 4. Start group mode change to multi-primary on the primary. |
| 9 |
# 5. While group action is ongoing on server1, server2 already |
| 10 |
# changed group_replication_enforce_update_everywhere_checks |
| 11 |
# but has super_read_only enabled. |
| 12 |
# 6. Complete the ongoing transaction. |
| 13 |
# 7. Successful termination of the group change. |
| 14 |
# 8. Clean up. |
| 15 |
################################################################################ |
| 16 |
--source include/have_group_replication_plugin.inc |
| 17 |
--let $rpl_skip_group_replication_start= 1 |
| 18 |
--let $rpl_group_replication_single_primary_mode=1 |
| 19 |
--source include/group_replication.inc |
| 20 |
|
| 21 |
|
| 22 |
--echo |
| 23 |
--echo ############################################################ |
| 24 |
--echo # 1. Bootstrap group on server1, which will be the primary. |
| 25 |
--let $rpl_connection_name= server1 |
| 26 |
--source include/rpl_connection.inc |
| 27 |
--source include/start_and_bootstrap_group_replication.inc |
| 28 |
|
| 29 |
CREATE TABLE tp1 (c1 char(10) NOT NULL PRIMARY KEY); |
| 30 |
CREATE TABLE tc1 (c1 char(10) NOT NULL PRIMARY KEY, |
| 31 |
FOREIGN KEY (c1) REFERENCES tp1(c1) ON DELETE CASCADE ON UPDATE RESTRICT); |
| 32 |
|
| 33 |
|
| 34 |
--echo |
| 35 |
--echo ############################################################ |
| 36 |
--echo # 2. Add a second member to the group. |
| 37 |
--let $rpl_connection_name= server2 |
| 38 |
--source include/rpl_connection.inc |
| 39 |
--source include/start_group_replication.inc |
| 40 |
|
| 41 |
|
| 42 |
--echo |
| 43 |
--echo ############################################################ |
| 44 |
--echo # 3. Start a transaction that has cascading FK on the primary. |
| 45 |
--let $rpl_connection_name= server_1 |
| 46 |
--source include/rpl_connection.inc |
| 47 |
BEGIN; |
| 48 |
INSERT INTO tp1 VALUES('a'); |
| 49 |
INSERT INTO tp1 VALUES('b'); |
| 50 |
INSERT INTO tc1 VALUES('a'); |
| 51 |
UPDATE tc1 SET c1 = 'b'; |
| 52 |
|
| 53 |
|
| 54 |
--echo |
| 55 |
--echo ############################################################ |
| 56 |
--echo # 4. Start group mode change to multi-primary on the primary. |
| 57 |
--let $rpl_connection_name= server1 |
| 58 |
--source include/rpl_connection.inc |
| 59 |
--send SELECT group_replication_switch_to_multi_primary_mode() |
| 60 |
|
| 61 |
--let $rpl_connection_name= server_1 |
| 62 |
--source include/rpl_connection.inc |
| 63 |
# Wait until the mode change starts waiting for ongoing transactions |
| 64 |
--let $wait_condition=SELECT COUNT(*)=1 FROM performance_schema.events_stages_current WHERE event_name LIKE "%Multi-primary Switch: waiting for pending transactions to finish" |
| 65 |
--source include/wait_condition.inc |
| 66 |
|
| 67 |
|
| 68 |
--echo |
| 69 |
--echo ############################################################ |
| 70 |
--echo # 5. While group action is ongoing on server1, server2 already |
| 71 |
--echo # changed group_replication_enforce_update_everywhere_checks |
| 72 |
--echo # but has super_read_only enabled. |
| 73 |
--let $rpl_connection_name= server2 |
| 74 |
--source include/rpl_connection.inc |
| 75 |
--let $wait_condition=SELECT COUNT(*)=1 FROM performance_schema.events_stages_current WHERE event_name LIKE "%Multi-primary Switch: waiting on another member step completion" |
| 76 |
--source include/wait_condition.inc |
| 77 |
|
| 78 |
--let $assert_text= group_replication_enforce_update_everywhere_checks is ON |
| 79 |
--let $assert_cond= [SELECT @@GLOBAL.group_replication_enforce_update_everywhere_checks] = 1 |
| 80 |
--source include/assert.inc |
| 81 |
|
| 82 |
--let $assert_text= The super_read_only mode must be 1 here. |
| 83 |
--let $assert_cond= [SELECT @@GLOBAL.super_read_only] = 1; |
| 84 |
--source include/assert.inc |
| 85 |
|
| 86 |
|
| 87 |
--echo |
| 88 |
--echo ############################################################ |
| 89 |
--echo # 6. Complete the ongoing transaction. |
| 90 |
--let $rpl_connection_name= server_1 |
| 91 |
--source include/rpl_connection.inc |
| 92 |
COMMIT; |
| 93 |
|
| 94 |
|
| 95 |
--echo |
| 96 |
--echo ############################################################ |
| 97 |
--echo # 7. Successful termination of the group change. |
| 98 |
--let $rpl_connection_name= server1 |
| 99 |
--source include/rpl_connection.inc |
| 100 |
--reap |
| 101 |
--source include/gr_assert_multi_primary_mode.inc |
| 102 |
|
| 103 |
--let $rpl_connection_name= server2 |
| 104 |
--source include/rpl_connection.inc |
| 105 |
--source include/gr_assert_multi_primary_mode.inc |
| 106 |
|
| 107 |
--source include/rpl_sync.inc |
| 108 |
|
| 109 |
--let $diff_tables=server1:tp1, server2:tp1 |
| 110 |
--source include/diff_tables.inc |
| 111 |
--let $diff_tables=server1:tc1, server2:tc1 |
| 112 |
--source include/diff_tables.inc |
| 113 |
|
| 114 |
|
| 115 |
--echo |
| 116 |
--echo ############################################################ |
| 117 |
--echo # 8. Clean up. |
| 118 |
DROP TABLE tc1; |
| 119 |
DROP TABLE tp1; |
| 120 |
|
| 121 |
--let $rpl_group_replication_single_primary_mode=0 |
| 122 |
--let $rpl_group_replication_reset_persistent_vars=1 |
| 123 |
--source include/group_replication_end.inc |