| 1 |
--source include/galera_cluster.inc |
| 2 |
--source include/have_innodb.inc |
| 3 |
--source include/have_debug_sync.inc |
| 4 |
--source include/galera_have_debug_sync.inc |
| 5 |
|
| 6 |
# |
| 7 |
# Testing CREATE TABLE statement having foreign key constraint, |
| 8 |
# while having concurrent DML for the referenced parent table. |
| 9 |
# |
| 10 |
# The replication of CREATE TABLE should have all referenced table names |
| 11 |
# appended in the key set, and DML on the parent table should be considered as |
| 12 |
# conflicting. |
| 13 |
# |
| 14 |
# There are related test scenarios in test mysql-wsrep#332, where a regular table |
| 15 |
# is altered by adding new foreign key reference. |
| 16 |
# |
| 17 |
# We use concurrency facility of test MW-369 to setup the conflict between DDL and DML |
| 18 |
# |
| 19 |
|
| 20 |
# Open connection node_1a here, we will use it later |
| 21 |
--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 |
| 22 |
|
| 23 |
# create FK parent table |
| 24 |
--connection node_1 |
| 25 |
CREATE TABLE p (id INTEGER PRIMARY KEY, f2 INTEGER) ENGINE=INNODB; |
| 26 |
|
| 27 |
# setup conflicting queries |
| 28 |
--let $mw_369_parent_query = INSERT INTO p VALUES(1,0) |
| 29 |
--let $mw_369_child_query = CREATE TABLE c(id INT NOT NULL PRIMARY KEY, p_id INT, FOREIGN KEY (p_id) REFERENCES p(id) ON DELETE CASCADE) ENGINE=InnoDB |
| 30 |
|
| 31 |
--connection node_1 |
| 32 |
SET AUTOCOMMIT=ON; |
| 33 |
START TRANSACTION; |
| 34 |
--eval $mw_369_parent_query |
| 35 |
|
| 36 |
# |
| 37 |
# Block the $mw_369_child_query from node_2 |
| 38 |
# |
| 39 |
# --connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 |
| 40 |
--connection node_1a |
| 41 |
SET SESSION wsrep_sync_wait = 0; |
| 42 |
--let $galera_sync_point = apply_monitor_slave_enter_sync |
| 43 |
--source include/galera_set_sync_point.inc |
| 44 |
|
| 45 |
# |
| 46 |
# insert client row, which will make it impossible to replay the |
| 47 |
# delete on parent |
| 48 |
# |
| 49 |
--connection node_2 |
| 50 |
--eval $mw_369_child_query |
| 51 |
|
| 52 |
# |
| 53 |
# Wait until $mw_369_child_query from node_2 reaches the sync point and |
| 54 |
# block the 'COMMIT' from node_1 before it certifies. |
| 55 |
# |
| 56 |
--connection node_1a |
| 57 |
--source include/galera_wait_sync_point.inc |
| 58 |
--source include/galera_clear_sync_point.inc |
| 59 |
|
| 60 |
--connection node_1 |
| 61 |
--send COMMIT |
| 62 |
|
| 63 |
--connection node_1a |
| 64 |
--let $galera_sync_point = apply_monitor_slave_enter_sync |
| 65 |
--source include/galera_signal_sync_point.inc |
| 66 |
--source include/galera_clear_sync_point.inc |
| 67 |
|
| 68 |
# Expect certification failure |
| 69 |
--connection node_1 |
| 70 |
--error ER_LOCK_DEADLOCK |
| 71 |
--reap |
| 72 |
|
| 73 |
--connection node_1a |
| 74 |
SET SESSION DEBUG_SYNC = "RESET"; |
| 75 |
|
| 76 |
--connection node_2 |
| 77 |
SELECT * FROM p; |
| 78 |
SELECT * FROM c; |
| 79 |
|
| 80 |
DROP TABLE c; |
| 81 |
DROP TABLE p; |