| 1 |
############################################################################### |
| 2 |
# This test validates that there are no fake foreign keys conflicts on Group |
| 3 |
# Replication while it is operating in single primary mode. |
| 4 |
# Test: |
| 5 |
# 0. The test requires three servers in SP |
| 6 |
# 1. Bootstrap start GR on server1 (Primary). Start GR on server2 (Secondary). |
| 7 |
# 2. Create two tables, one with a foreign key |
| 8 |
# 3. Block all send requests to the group |
| 9 |
# 4. Execute a transaction with FK=1 that will block (T1) |
| 10 |
# 5. Wait for it to block |
| 11 |
# 6. Execute another transaction with FK=1 that will also block (T2) |
| 12 |
# 7. Wait for it to block. Unblock both transactions |
| 13 |
# 8. Fetch outcome of transaction T1. |
| 14 |
# 9. Fetch outcome of transaction T2. |
| 15 |
# 10. Check data consistency. |
| 16 |
# 11. Cleanup |
| 17 |
# |
| 18 |
############################################################################### |
| 19 |
--source include/big_test.inc |
| 20 |
--source include/have_debug_sync.inc |
| 21 |
--source include/have_group_replication_plugin.inc |
| 22 |
--let $rpl_skip_group_replication_start= 1 |
| 23 |
--let $rpl_group_replication_single_primary_mode=1 |
| 24 |
--source include/group_replication.inc |
| 25 |
|
| 26 |
--echo |
| 27 |
--echo ############################################################ |
| 28 |
--echo # 1. Bootstrap start GR on server1 (Primary). |
| 29 |
--echo # Start GR on server2 (Secondary). |
| 30 |
--let $rpl_connection_name= server1 |
| 31 |
--source include/rpl_connection.inc |
| 32 |
--let $server1_uuid= `SELECT @@server_uuid` |
| 33 |
--source include/start_and_bootstrap_group_replication.inc |
| 34 |
|
| 35 |
--let $rpl_connection_name= server2 |
| 36 |
--source include/rpl_connection.inc |
| 37 |
--source include/start_group_replication.inc |
| 38 |
|
| 39 |
# Make sure server1 is the primary |
| 40 |
--let $assert_text= Verify group_replication_primary_member is SERVER_UUID |
| 41 |
--let $assert_cond= "[SELECT VARIABLE_VALUE FROM performance_schema.global_status WHERE VARIABLE_NAME= \'group_replication_primary_member\', VARIABLE_VALUE, 1]" = "$server1_uuid" |
| 42 |
--source include/assert.inc |
| 43 |
|
| 44 |
--echo |
| 45 |
--echo ############################################################ |
| 46 |
--echo # 2. Create two tables, one with a foreign key |
| 47 |
--let $rpl_connection_name= server1 |
| 48 |
--source include/rpl_connection.inc |
| 49 |
CREATE TABLE t1 (c1 INT PRIMARY KEY, c2 INT, KEY(c2)); |
| 50 |
INSERT INTO t1 VALUES (1,1); |
| 51 |
CREATE TABLE t2 (c1 INT PRIMARY KEY, c2 INT, FOREIGN KEY (c2) REFERENCES t1(c2)); |
| 52 |
|
| 53 |
--source include/rpl_sync.inc |
| 54 |
|
| 55 |
--echo |
| 56 |
--echo ############################################################ |
| 57 |
--echo # 3. Set a debug sync before broadcast message to group. |
| 58 |
--let $rpl_connection_name= server1 |
| 59 |
--source include/rpl_connection.inc |
| 60 |
SET @debug_save= @@GLOBAL.DEBUG; |
| 61 |
SET @@GLOBAL.DEBUG='d,group_replication_before_message_broadcast'; |
| 62 |
|
| 63 |
--echo |
| 64 |
--echo ############################################################ |
| 65 |
--echo # 4. Commit transaction T1 that will be blocked before broadcast. |
| 66 |
--let $rpl_connection_name= server_1 |
| 67 |
--source include/rpl_connection.inc |
| 68 |
BEGIN; |
| 69 |
INSERT INTO t2 VALUES (1,1); |
| 70 |
--send COMMIT |
| 71 |
|
| 72 |
--echo |
| 73 |
--echo ############################################################ |
| 74 |
--echo # 5. Wait until transaction T1 reaches the |
| 75 |
--echo # group_replication_before_message_broadcast debug sync point. |
| 76 |
--let $rpl_connection_name= server1 |
| 77 |
--source include/rpl_connection.inc |
| 78 |
--let $wait_condition=SELECT COUNT(*)=1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE State = 'debug sync point: now' |
| 79 |
--source include/wait_condition.inc |
| 80 |
|
| 81 |
--echo |
| 82 |
--echo ############################################################ |
| 83 |
--echo # 6. Commit transaction T2 that will be blocked before broadcast. |
| 84 |
--let $rpl_connection_name= server_1_1 |
| 85 |
--source include/rpl_connection.inc |
| 86 |
BEGIN; |
| 87 |
INSERT INTO t2 VALUES (2,1); |
| 88 |
--send COMMIT |
| 89 |
|
| 90 |
--echo |
| 91 |
--echo ############################################################ |
| 92 |
--echo # 7. Wait until both transactions reach the |
| 93 |
--echo # group_replication_before_message_broadcast debug sync point. |
| 94 |
--echo # Signal both transactions to resume the its path. |
| 95 |
--let $rpl_connection_name= server1 |
| 96 |
--source include/rpl_connection.inc |
| 97 |
--let $wait_condition=SELECT COUNT(*)=2 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE State = 'debug sync point: now' |
| 98 |
--source include/wait_condition.inc |
| 99 |
SET DEBUG_SYNC='now SIGNAL waiting'; |
| 100 |
SET DEBUG_SYNC='now SIGNAL waiting'; |
| 101 |
SET @@GLOBAL.DEBUG= @debug_save; |
| 102 |
|
| 103 |
--echo |
| 104 |
--echo ############################################################ |
| 105 |
--echo # 8. Fetch outcome of transaction T1. |
| 106 |
--let $rpl_connection_name= server_1 |
| 107 |
--source include/rpl_connection.inc |
| 108 |
--disable_warnings |
| 109 |
--reap |
| 110 |
--enable_warnings |
| 111 |
|
| 112 |
--echo |
| 113 |
--echo ############################################################ |
| 114 |
--echo # 9. Fetch outcome of transaction T2. |
| 115 |
--let $rpl_connection_name= server_1_1 |
| 116 |
--source include/rpl_connection.inc |
| 117 |
--disable_warnings |
| 118 |
--reap |
| 119 |
--enable_warnings |
| 120 |
|
| 121 |
--echo |
| 122 |
--echo ############################################################ |
| 123 |
--echo # 10. Check data consistency. |
| 124 |
--let $rpl_connection_name= server1 |
| 125 |
--source include/rpl_connection.inc |
| 126 |
--source include/rpl_sync.inc |
| 127 |
|
| 128 |
--let $assert_text= Table t2 contains one row with c1=1 |
| 129 |
--let $assert_cond= [SELECT COUNT(*) AS count FROM t2 WHERE t2.c1=1, count, 1] = 1 |
| 130 |
--source include/assert.inc |
| 131 |
|
| 132 |
--let $assert_text= Table t2 contains one row with c1=2 |
| 133 |
--let $assert_cond= [SELECT COUNT(*) AS count FROM t2 WHERE t2.c1=2, count, 1] = 1 |
| 134 |
--source include/assert.inc |
| 135 |
|
| 136 |
--let $diff_tables= server1:test.t1, server2:test.t1 |
| 137 |
--source include/diff_tables.inc |
| 138 |
--let $diff_tables= server1:test.t2, server2:test.t2 |
| 139 |
--source include/diff_tables.inc |
| 140 |
|
| 141 |
--echo |
| 142 |
--echo ############################################################ |
| 143 |
--echo # 11. Clean up. |
| 144 |
|
| 145 |
DROP TABLE t2; |
| 146 |
DROP TABLE t1; |
| 147 |
|
| 148 |
--source include/group_replication_end.inc |